/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Attached: file.png (800x800, 326K)

Other urls found in this thread:

github.com/rust-lang/cargo/pull/4817
craftinginterpreters.com/
arewewebyet.org/
play.rust-lang.org/?gist=11b8cb9088b0f8c36048a54ee293f537
twitter.com/SFWRedditGifs

r8

Attached: 1504644233392.png (599x515, 30K)

Too much of a brainlet to program. Like, two years has passed by and I am still not able to write anything complex.

Should I kys?

You'll never get good at what you don't train to do.
So you should try to write something complex if you want to get good at that.
I don't think you're actually unable. The only difficulty in writing complex systems is doing it well.

what can you code up
what do you want to code up?

What do you mean by a complex program?

"clever" in a bad way

So, it seems that I'll finally start my first job (after three years of NEETdom) as an apprentice software developer.
It never said in the description but it turns out that they primarily write in C# and use Visual Studio.
class HelloWorld{
static void Main() => System.Console.WriteLine("Hello world!");
}

As someone who's never worked before in their life, what have I let myself into?

Attached: Why.jpg (745x327, 43K)

I'm a bit ambivalent about Rust the language, but the basic tooling around it is really impressive and well-designed. Cargo, Rustfmt, Racer, fantastic compiler error messages, and a compiler that can do some really crazy shit when you inspect output.

I tested rustc -O on godbolt for a bit. It's crazy good at global optimizations, it can transform a long iterator chain with functions from different modules into an O(1) formula.

What's the problem exactly?

Yeah as much as I'm not interested in Rust I'll give it to them that Cargo is absolutely amazing. I wish every programming language had its own equivalent that's on par.

It's only shit that C++ can do with inline functions. Does Rust even have incremental compilation?

Google a bunch of programming exercises and puzzles. Keep trying to solve them until you get it. It comes with time and practice.

Game dev stuff atm

Mostly multiplayer character persistence

>posted 90 seconds apart
Pathetic

What's your workflow? Unity + Visual Studio? Thinking of getting into this

Oh thats a cool way to do that~
Now make a program that gives you an X of an arbitrary(Either odd or even dumbers dont work, cant remember which, so you can skip those if youd like) number of lines

Attached: out.png (342x626, 6K)

I'm uncertain about working, about the language and about the IDE.
Language-wise, I learned Java from uni and C from K&R.
IDE-wise, I've installed VS and it lags heavily (at least on my machine; I'll find out how it fares on the company computers when I start); I've only used Notepad++ and the console (JEdit and console for Java).

For the game client : vim and unreal engine.
For the http based persistence layer: scala and intelllij.

Database migrations are in ruby

C# should be fairly straightforward coming from Java. There's some extra shit but that's largely thin wrappers over things already doable in Java.

>Does Rust even have incremental compilation?
No, and it never will, because it can't compile files separately, it has to parse everything and then process it in one giant chunk
It allows you to have files foo and bar with functions in bar that depend on types defined in foo and functions in foo that depend on types defined in bar
It's doomed to always be slow at compilation

Last time I did somewhat "complex" is writing a small console card game, where two players used to play against each other (actually it's a simple loop checking the necessary conditions and making a move if it's viable).

I'd like to write a small interpreter for language.

Attached: wallhaven-251383.png (2560x1440, 488K)

Yes. It's enabled by default since Rustc 1.24
github.com/rust-lang/cargo/pull/4817

90 seconds is the image cooldown.

def printX(n: Int) = {
def line(i: Int) = println(" "*i + '#' + " "*(2*(n-i)-1) + '#')

for (i

>I'd like to write a small interpreter for language.
craftinginterpreters.com/
Get crackin'

Oh and less unexpected null refrences and throws.
Not to mention that you longer have to download everything apache and google made especially for you and the httpclient actually werks.

>>less unexpected null refrences
>implying this happens
>>and throws
>implying this is bad

How do I get people to join my peer to peer chat?

Give them your IP

c# / visual studio is a very pleasant experience if your computer can handle it. really easy to get into, not too many gotchas, solid career. the only downside really (and an important one) is that you rely on microsoft's choices.

>(COMING SOON)
>(COMING SOON)
>(COMING SOON)
>(COMING SOON)
>(COMING SOON)

how's that different from relying on an iso committee?
Or mozilla, oracle, etc.

excuses, excuses

complementary bjs

No-one wants to be hacked, sorry.

So I've been reading about formal verification in C. Say, you've got an integer array, and you want a function that returns a maximal element of it (with no side effects). With ACSL, you can specify it this way:
/*@ requires n > 0;
requires \valid(p+ (0..n-1));
assigns \nothing;
ensures \forall int i; 0 = p[i];
ensures \exists int e; 0

Anyone noticed a certain pattern in life?
Newer programs are getting named 'photon', 'quantom' and 'phantom'... again

picrel

Attached: 1500199337112 python analysis paralysis pepe.png (971x280, 94K)

pussy

You start with easy shit. Automate.

the bootstrap string has ip, port, and a hash of the peer's public key
everyone too scared to run an opensource js app
I think if I add file sharing people will be more interested, it'll be like bittorrent + chat

Yup, the old dogs often talk about the cycles for most types of IT trade-offs
- thin vs thick clients
- static vs dynamic typing
- and so on

>everyone too scared to run an opensource app
>heartbleed dont real
open sores is no guarantee of trustworthiness, it merely removes one handicap in the long process of establishing it

The chat uses kademlia for the peer table. The distance between peer ids is the xor of the ids. For the ids I'm using the hash of a public key that gets generated when the client starts. The messages to the peers in your peer table are verified (id is hash of public key, messages signed with corresponding private key).

New peers announce their public key to the network, but the whole network doesn't send their keys back, it could be overwhelming for large numbers of peers. Instead, you're gonna be able to verify messages. This'll send a request to the peer who allegedly sent the message requesting their public key, if the key hashes to the id that sent the message, and the signature checks out, that message (and any others sent by the peer) will get marked as verified.

With these keys I should be able to sign the parts of a DH key exchange. I'm going to have subchats (not implemented yet) that are fully end to end encrypted. In the subchats I want to make it possible to advertise a list of files and transfer those between peers (verified and encrypted).

>p points to a valid array of n elements
In Idris, you would have an argument of type `Vec Int n`.

>the function does not modify memory
Typically enforced by purity, possible to enforce with linear types using the exponential !.

>n is non-zero
>the result is equal to or more than any element of an array
>the result is equal to at least one element of the array
You can straightforwardly translate logical formulae to types. `x==y`, `x>y`, etc. are types that are inhabited iff they are true, ∀ is a dependent function and ∃ is a dependent pair. Because the proof that `n>0` is an assumption, you can use it to eliminate the empty case from pattern matching.

is functional programming the future or just a meme?

it's the past

What language is that?

It will always be the underdog, nudging mainstream languages in the right direction without gaining the attention they deserve.

Aye, I appreciate it. It looks a lot like Java so far.
That said, though, I feel completely unconfident writing in Java: my uni was more concerned with getting everyone writing half-functioning programs that none of the concepts (or what I was even doing) never sunk in at the time; the lecturers said they would've been happier teaching Fortran.

I assume that, at this stage, Microsoft's C# programming guide will suffice to get me up to speed.
Would Hejlsberg's book be recommended (as in, is it comparable to K&R)?

Well, my computer's been unable to handle it with elegance so far.
I've added the compiler to the environment variables and plan to use what I'm familiar with, for purposes of learning the language; that said, VS had already given a suggestion (using "=>") that I would've been unaware of without it, so I understand that I'll be at a disadvantage using my current setup.

And That's A Good Thing

Not sure what I was thinking when I made this.
It finds a function that fits the input to the output, though not necessarily the one that was used to generate the output.

function reg(input, output)
local t = {}
local aux
local integer
local integer2
local decimal
local decimal2
while true do
aux = math.log(output)/math.log(input)
integer = math.floor(aux)
decimal = aux - integer
table.insert(t, integer)
aux = math.pow(input, decimal)
integer2 = math.floor(aux)
decimal2 = aux - integer2
aux = math.pow(input, integer) * decimal2
table.insert(t, integer2)
output = aux
if output < input then
break
end
end
-- output is less than input
-- it becomes coefficient and expoent is 0
table.insert(t, 0)
table.insert(t, output)
return t
end

function format(t)
local i = 1
while i < #t do
io.write(t[i+1].."*x^"..t[i].."+");
i = i + 2
end
io.write("\n")
end

format(reg(3,16))
format(reg(5,100))

$ lua reg.lua
1*x^2+2*x^1+1.0*x^0+
4*x^2+8.8817841970013e-14*x^0+

when will /dpt/ be cured of its crippling Sup Forumsio

Well, how would it look in actual code? Can you write it if it's no bother? It's just that most of the examples for Idris that I found assert only the basest of things like the length of the vector the function returns.

>t. Fizz Buzzington and his crew of merry code golfers

I really hate Rust because of the CoC and cucks, but I have to admit that it's technically superior to C and C++ in every way. I wish every language was like Rust, but I'm sticking with C++. True story.

Rust package manager just leads to dependency hell, more of a human / project problem but still fucking awful to work with.

How do you even get into dependency hell with Cargo? Are you relying on C libraries?

>not using a golfing-oriented language for your code golf problems
amateur tier up in this bitch

You know, guys, I myself am kinda iffy about Rust, so you know I'm not just a shill, but I can't help but admit how efficient and well-designed it is. It has many advantages over other systems programming languages, like zero-cost abstractions, memory safety and fearless concurrency.

>not just a shill
>unironically using "fearless concurrency"

When "fearless concurrency" implies I can't obtain multiple mutable references to an object in a single threaded environment, it isn't worth it.

What do you mean? I literally said I'm not sure about Rust. How can I be a shill?

I was looking at the web server/app framework iron. The components of it all rely on different versions of iron or database connectors which absolutely fucks the build with ambiguous error messages. Maybe there is some work around but I couldn't find it after a few days or looking / trying stuff. I recognize it's not a web language, but it pretty quickly fell apart with a handful of packages that depended on different versions of the same things.

If you don't find anything wrong with unironically using the phrase "fearless concurrency", you haven't been in the industry long enough.

arewewebyet.org/

>he supports fearful concurrency
This is the kind of talk that makes me think Rust is actually the superior language...

>yet
The question is why should you? What's the point of using something like Rust for web backend and spending much more time on it than necessary instead of just using one of these simple languages that have established frameworks and documentations where you can get stuff done real quick and forget about it.

>What's the point of using something like Rust for web backend
You're right, it should be used for web frontend

How about... neither?

Or, or better yet, BTOH

>What's the point of using something like Rust for web backend
Because it supports advanced type-theoretic concepts like borrow-checking, and because it doesn't compile incorrect programs; if it compiles, it works.

Can you style a rect in a html5 canvas using css?

No. What kind of sense would that even make?

>because it doesn't compile incorrect programs; if it compiles, it works.
play.rust-lang.org/?gist=11b8cb9088b0f8c36048a54ee293f537

...

That doesn't prove anything, retard. Try actually learning Rust.

Bettered the ouput a bit.

$ lua reg.lua
f(3)=16
f(x)=x^2+2*x+1
f(5)=100
f(x)=4*x^2+8.8817841970013e-14
f(3)=8
f(x)=2*x+2
f(3)=2
f(x)=2

>resorting to namecalling
Sure you showed me.

Not an argument. You literally didn't prove anything.

Resorting to insults shows you've run out of arguments.

You said Rust doesn't produce incorrect programs to which I have proved you wrong. Instead of addressing an obvious flaw like an adult being you resorted to name calling because you obviously had no argument to your false claim. Don't bother replying.

>You said Rust doesn't produce incorrect programs to which I have proved you wrong.
You didn't prove anything. It's still true that Rust only compiles correct programs.

code golf is quite possibly the gayest of hobbies

Bad dragon (male) product reviewer is a pretty good contender though.

>supports using "fearless concurrency" as a term
You've got management written all over you, kid. That or PR lizard.

You can? Just use refcell if you want your shared object to have mutable fields.

Is programming still a profitable career?

Attached: kc5.jpg (608x960, 44K)

>dynamically checked borrow rules
it's shit

You're just another anti-Rust language shill who loves concurrency bugs and stack corruption, and this is coming from someone who doesn't even like Rust.

compared to?

You're retarded.
I find their ideas great.
The marketing language, on the other hand, reminds me that SJWzilla is full of propaganda cunts.

>compile program
>an error shows up
>"b-but that doesnt prove my 'if it compiles, it works' argument wrong! you didn't prove anything!!"

Rust is an amazing language. Too bad about annoying shills like you giving it a bad name. Most of Sup Forums already understands that Rust is the future, so there's no need for this sort of shilling.

>Learn You a Haskel For Great Good!
or
>Haskellbook.com
?????

Attached: 1497664546728.png (480x270, 152K)

fn main() {
for i in 1..102 {
match (i%3, i%5) {
(0, 0) => println!("FizzBuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
(_, _) => println!("{}", i)
}
}
}

I used to think C++ was great, but Rust is just so elegant...

help me test my sketchy peer to peer chat app?
party-line.lol

haskell wikibook

I just found this way of declaring module-scope variables and functions in C. Do you think it's good form?

example.h:
#define PRIVATE static
#define PUBLIC /* nothing */


Now I can define variables and functions that are "private" to the example.c source file.

example.c:
#include "example.h"

/* Private variables: can only access from this module */
PRIVATE int miNumbers[STACK_SIZE] = {0};
PRIVATE int miPosition = 0;
PRIVATE float fAverage = 0.0;

PRIVATE void
terminate(const char * sMessage) {
printf("%s \n", sMessage);
exit(EXIT_FAILURE);
}