/dpt/ - Daily Programming Thread

There's literally nothing wrong with typedefing a pointer edition

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/questions/12818800/should-i-leave-the-bluetooth-reflection-hack-in-production-code
doc.rust-lang.org/book/second-edition/
packtpub.com/application-development/rust-essentials
doc.rust-lang.org/book/
github.com/vulkano-rs/vulkano).
benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html
twitter.com/steveklabnik
youtube.com/watch?v=rVxk5frP9Fg
twitter.com/SFWRedditImages

Daily reminder that Java programmers are simple and "Rustaceans" are schizophrenic

...

Codemonkey wageslave here.
How do I make myself stop browsing Sup Forums and actually do my job?
I haven't written one line of code since last Friday. I think the boss might be on to me.

Java is unironically good

Nice try

Daily reminder to watch out for the schizophrenic Rust false-flagger who claims that anyone who shits on Rust is the same person, and pretends to be me.

>Bluetooth support on recent Android versions is so broken you have to manually invoke protected/private methods via Reflection to make it work as intended
Is this real life

That was enterprise quality!

All these anti rust shilling has gotten me interested in Rust. Has anyone got a recommended book on it?

>>>/prog/

stackoverflow.com/questions/12818800/should-i-leave-the-bluetooth-reflection-hack-in-production-code
>2012
>recent

doc.rust-lang.org/book/second-edition/
packtpub.com/application-development/rust-essentials

Unlike C/C++ Rust doesn't make you depend on books.

Thanks.

Nothing has been printed yet afaik because it's a fast-moving target. Rustfags mostly recommend doc.rust-lang.org/book/ what you read might end up invalidated at some point, but it's certainly intellectually entertaining and when Rust becomes mainstream (troll intended) you'll have a competitive head start.

What did get invalidated after version 1 came out?

Nothing, he's talking out of his ass, like most (if not all of the) anti-rust memelords.

>start working with ocaml
>realize that literally every other programming language is garbage

0.002 cents have been deposited to your single threaded language evangelism campaign. Keep up the good work.

Le GIL faec

Why is there a v2 then? I have no positive proof that the language or stdlib changed in a backwards incompatible way, but no evidence to the contrary either. And even if they don't, new features such as placements may change the usual Rust programming style so much that strictly reading the v1 book isn't enough, so...?

It's okay, 99% of dpt has never written any multithreaded code.

Do you mean Rust 1.0 or TRPL first edition?

Is this user doing the right thing?

Rust shills really need to kill themselves. Nim is vastly superior.

>Why is there a v2 then?
Where exactly is v2?
> I have no positive proof that the language or stdlib changed in a backwards incompatible way
Of course you don't.
> but no evidence to the contrary either.
You claimed otherwise and so the burden of proof is on you
>new features such as placements may change the usual Rust programming style
That's not backwards incompatibility. Even so, can you show me an example where this happened?
(Suddenly remember when C++11 came out)

WE STAND FOR JAVA

END THIS LBGTB FEMINIST RUST MADNESS

>Java
Why do you feel that Rust competes with virtual machine languages?

Guys, I have an array of coordinates (x,y), I want to get the euclidean distance between all of them, is there a better solution than my shitty O(n2) solution?
for(i=0;i

Is that supposed to be a justification?

There is a second edition to the book. What are the differences between them?
>That's not backwards incompatibility.
Could still partially invalidate the book
>C++11
Was game changing and required updating your knowledge indeed. I'm not trying to bad mouth Rust nor the book, nor promote sepples, I'm just saying what I see

What the fuck?

yes why are you such a brainlet that you think a weaksauce scripting language is somehow better than C#/C++ for building non-trivial software

>There is a second edition to the book. What are the differences between them?
Because the first edition was not written very well and the authors decided to publish a second edition. Anything wrong with that?
>Could still partially invalidate the book
What update made the book "invalid"?
> I'm just saying what I see
Yeah, judging by the depth of your perception, I doubt you can look close

Languages break backwards compatibility all the time, I wouldn't be surprised if Rust did so. See: C++

>yes why are you such a brainlet that you think a weaksauce scripting language is somehow better than C#/C++ for building non-trivial software
Reminder that developers of nontrivial games try to keep the amount of C++ code at the bare minimum necessary for performance, and use custom scripting languages whenever they can get away with it. Nobody wants to work with the absolute trash that is C++ more than necessary, least of all for gameplay development.

>C#
>Non trivial software
Rakesh, please.

>Because the first edition was not written very well and the authors decided to publish a second edition. Anything wrong with that?
Nothing. Fair point.

>What update made the book "invalid"?
No one can guarantee nothing significant is introduced into the language between the moment user reads the book and the moment Rust becomes mainstream. That's my point. That doesn't mean it's already 100% useless, only that it ain't the gospel. Jeez, is that too difficult for you to understand?

MYSQL

Whats the simplest and quickest way to log a row's state BEFORE and AFTER an update query?
What I'm doing now is basically making a select with the where clause, saving the row in memory, making the update, and then inserting into the log the select result and the variables I know from the update query.
This is all manually in code where I call the queries.

I really think there should be a way to automate this, but I can't find it.

Are these true?

USE LISP

better than fucking GDscript or lua

>Graphics API
For Rust users, I would recommend Vulkano (github.com/vulkano-rs/vulkano). Rust likes to take control of the dependency management for you, so you don't have to deal with nasty build systems like autotools to manage external libraries.

for non-brainlets yes

>learning how to develop your game from scratch (that is, not relaying in game engines such as unity and GMS) will take you closer to deploying a game and beat your competitors.
Completely delusional. By the time you're done developing your half-assed bug-ridden toy engine and start trying to develop an actual game, "your competitors" will have released five of them. By the time you finish the actual game, your visuals will have become outdated compared to what users of crap like Unity get out of the box. The people who think like this poster are stuck perpetually in the engine development phase and never release a game.

enjoy making sub $100 off of your shitty unity game

>start Python interpreter
>type the following

>>> a = 1
>>> b
Traceback (most recent call last):
File "", line 1, in
NameError: name 'b' is not defined
>>> if a == 1:
... b = 2
...
>>> b
2


What gives? How is b = 2 if it previously reported NameError. If I type this in the file, it would fail but it works in interactive session. Is this a bug? Because it seems that interpreter reserves a memory space for b in interactive session, but not when I write it in a script file.

/dpt/ BTFO

>enjoy making sub $100 off of your shitty unity game
I'd even say that's optimistic, but either way: enjoy making $0 off a game that never gets released.

The interactive session behave a bit differently than scripts. If it didn't it would exit in your face once you get the "b is undefined" error, just like scripts. But it's forgiving and it lets you continue typing more commands.

>boxplot
>y axis is exponential
This tickles my autism

>How is b = 2
You defined it
>it previously reported NameError
it wasn't defined at that time
>If I type this in the file, it would fail
Execution stops at first unhandled exception before b is defined
I don't really get what you miss.
Maybe you think variables are defined at compile time? Well that's wrong.

Whoa, the rust shilling spreading to other boards like ebola.

FYI, the idea of that benchmark series is not to rank language according to its efficiency. It's just to give you a rough idea which languages are faster. Yes, Rust and C++ are at the same ballpark. This doesn't mean that C++ is always slower than Rust (and so on).

the scripting languages are for designfag nonprogrammers. maybe is more your thing than trying to make a game engine in fucking C and a game in fucking lua

>Yes, Rust and C++ are at the same ballpark.
They're not, see Median C++ performance is a lot lower than median Rust performance.

Nobody gives a fuck about Sup Forums or /vg/, stop making these posts

It doesn't mean that, but it's true, especially when using the same code

Also, the updated version

benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html

...

>calling me a faggot for pointing out flaws in your argument and posting updated numbers
Great argument, go back to please.

What makes you think I'm from Sup Forums, my salty little SJW?

>Also, the updated version
Doesn't go against my claim

Because you think understanding statistics is for faggots. Maybe you're not from Sup Forums, but you certainly belong there.

Explain these then: Looks like your argument just fell apart.

What is your claim?

My point is that it shows that C++ has a lower median runtime as well as smaller variance than Rust.

Yeah, I have defined b within the local scope of conditional (or rather I've assigned a value to it). But previously I haven't assigned any value to b, when I typed '>>> b' and got a NameError. So I thought that later on it wouldn't print b because it's only assigned in the local scope

>What is your claim?

>the scripting languages are for designfag nonprogrammers.
The scripting languages are for everything except engine core.

>maybe is more your thing than trying to make a game engine in fucking C and a game in fucking lua
I've written a game engine in C more times than you've had a birthday, kid. And, like everyone else who knows what they're doing, I use a custom scripting engine from all UI and gameplay code.

He's a massive faggot, what else is there to say

>Explain these then
Rust shills don't count as people, so "nobody cares" still stands.

Yeah they count as gods, so your ``point" still stands

my bad, you're right. It's a conditional *within* a global namespace. I get it now

>the idea of that benchmark series is not to rank language according to its efficiency. It's just to give you a rough idea which languages are faster
Correct, or as stated in the actual source:

>How many times slower, the fastest benchmark programs for selected programming language implementations are, compared to the fastest written in any of the programming languages.

benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html

>Rust and C++ are at the same ballpark.
I dispute this, as runtime distributions are shown on a logarithmic axis, thus hiding the true distributions.

>This doesn't mean that C++ is always slower than Rust (and so on).
Assuming "always" mean "always for nbody calculation [aka the benchmark]", that's wrong. The point of doing multiple runs and showing the distribution *is* to say, with a certain level of statistical significance, that one language is faster than the other.

However, *my* point is that in both the february and november graph, the median performance of C++ is lower than Rust. In addition, seeing how y-axis is logarithmic, the difference is considerably larger than what it might appear if you're not aware of this.

Where’s clang?

>I dispute this, as runtime distributions are shown on a logarithmic axis
Thing is, the distributions change every months but the median remains roughly the same, if you look closely, Rust is very, very close to C++, especially if you compare Rust to the closest that Fortran axis.

By now it has gotten to the point that it became a benchmark between LLVM and GCC, to be quite honest.

Also, see how nicely the graph classifies these languages in three category, fast-faster-fastest and Rust belongs to the Fastest category

>the distributions change every months but the median remains roughly the same, if you look closely,
Indicates that the number of repeated runs is too small, IMO.

>Mentally ill people are likely to kill me
No shit

The scope in python differs too much from C-like languages.

Personally, I hope he (and the rest of his crew) does get killed by Nazis. Is that bad?

>tfw hasklel
>tfw f-sh**p
>tfw poocaml

No, I don't think anyone ITT wants you alive either.

antifa rustqueers BTFO

How so?

C++ is better in every single way including performance

Found the Rustlet. :^)

Functional languages don't claim to be fast.

>C++ is better in every single way
Enjoy managing third party libraries.

Found the C.uck

Daily reminder that this is what average rust core team member looks like
He will also punch you if you are nazi

Does anyone have a good resource to study Clojure? I tried reading the Brave and the true book but it made me want to run up a wall. It's full of dead-text/senseless filler in which no knowledge is conveyed: stupid jokes, idiotic references to various works of fiction, tedious practical examples based on said stupid jokes (if I have to read one more line about trolls, gnomes coding and Harry Potter references I am going to strangle a baby).
The guy also has a retarded tendency to give examples that are wrong and then correcting them instead of teaching proper practice from the start and explaining why the syntax works as it does. He also has an annoying habit of introducing new functionality haphazardly and deferring the explanation for later. I couldn't finish reading this book.

In short: please give me a Clojure source that is not written by a retard.

(((third party libraries)))

My language will have a kind for writing generics over lists of types. Ts: [K] declares that Ts is a list of types of kind K. You can wrap code in square brackets to abstract over lists of types interpreted as tuples.
Here's a function for mapping over tuples.
fn map{Ts: [Type], Us: [Type]}(f: [impl Fn(Ts) -> Us], x: [Ts]) -> [Us] {
[f(x)]
}

Here's how it would look if it were instantiated for Ts = (Foo, Bar) and Us = (Baz, Qux).
fn map(f: (impl Fn(Foo) -> Baz, impl Fn(Bar) -> Qux), x: (Foo, Bar)) -> (Baz, Qux) {
(f.0(x.0), f.1(y.1))
}

Here's some more involved code which implements a simple vector with structure-of-arrays memory layout.
struct Vector(Ts: [Type]) {
capacity: Uint,
length: Uint,
items: [^Ts]
}

impl{Ts: [Type]} Vector(Ts) {
fn new() -> Self {
Vector { capacity = 1, length = 0, items = [heap::alloc(1)] }
}

fn delete(self) {
[heap::free(self.items)];
}

fn extend(^self) {
self->capacity *= 2;
[heap::realloc(self->items, self->capacity)];
}

fn push(^self, item: [Ts]) {
if self->length == self->capacity {
self->extend();
}
[*(self->items + self->length) = item];
self->length += 1;
}

fn pop(^self) -> [Ts] {
self->length -= 1;
[*(self->items + self->length)]
}
}

Example:
fn main() {
let v: Vector((I32, F32)) = Vector::new();
v.push((12, 3.4));
let (i, x) = v.pop();
v.delete();
}

There's no reason not to be able to fold over tuples like this at the term level (it would complicate the type system too much if it were possible at the type level), but I haven't thought of syntax for that yet. Note that this syntax doesn't interfere with array syntax because expansion occurs in prefix position [e] whereas the latter appears in mixfix position e[n].

Look at how much of a raging commo he still is:

twitter.com/steveklabnik

>He will also punch you if you are nazi
Too weak. I will shoot you in the head point blank if you are a nazi.

youtube.com/watch?v=rVxk5frP9Fg

(((Nice (((parens))))))

>muh nut zees
>implying mentally ill transfags are allowed to own a gun in your liberal gun-free-zone state

I'm trying to learn Haskell but I'm so damaged by imperative programming that I feel completely handicapped. How to solve this?

Only good nazi is a dead one.
I'm no burgercuck, really.