/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

github.com/rust-lang/crates.io-index`
news.ycombinator.com/item?id=2822114
tockos.org/
en.wikipedia.org/wiki/100_Gigabit_Ethernet
twitter.com/NSFWRedditImage

First for C++ is shit.

I love you all

whom'st've for these posts are not programming please stay on topic

Why do they keep making C++ bigger every year?

Do they suffer from some sort of inferiority complex? C++ is INSANE, not even a 1500 pages book will teach you half of the language.
C with RAII when? WHEN!

>D
Slow. LDC, please for fuck's sake try and produce binaries that doesn't make fun of itself in comparison to the other systems languages. Dub is a JOKE in comparison to cargo and Dscanner/DCD server is just sad and pathetic compared to Rust's racer/RLS. Doesn't have many static analyzing options
>C
Too small, lacks too many features. The exact opposite of C++. If the compilers would be able to inject free() in sources during compilation that would be fucking great. I don't use C for the same reason I don't use Rust as my to-go language.
Also C macros are pitiful
>Rust
Holy shit the level of verbosity and complexity! 10/10 in getting in your way of thinking.
To be fair that's the same thing python fags complain about C. Learning C made me lazy just like learning python did.
Language is unplanned, it doesn't know what to have, what not to have and Rust certainly doesn't have syntax or library names that make sense for the most part, the incremental updates will make it worse than C++ in a couple of years.

Don't get me wrong, I personally like Rust. But holy shit there are so many things that need to mature
1. Has print! but doesn't have read!. println! flushes the stdio, print! doesn't.
Oh, you really don't need read! You need eprint! --makes SO MUCH sense!
2. for loops have i..z-1 (exclusive) syntax but pattern matching has i...z (inclusive) syntax
3. thousands of ways of doing the same thing
4. If you are indirectly pushing the functional programming practices why not adopt it fully? Add Higher Kinded Types
5. Lack of for(int i=0; ;) loop
Even C has it since C99


Thanks for reading my blog. I had to get that out of the system.

like english, but if you don't know it well enough then you are worthless trash

There is literally no reason to know C++.

people in Bolivia thinks the same of english

What the hell does that have to do with C++ being fucking shit?

dumb people in Bolivia = (You)
english = C++

>what are video games
>what is anything that requires performance and which isn't a legacy C application

C is the choice for high-performance applications though.

To elaborate this code is not valid in Rust
It's INSANE!
fn main() {
let x :u64 = 7u64 + 3i32;
let y :f32 = 7i32/3f32;
let y :f32 = 7i32/3i32;
}

I use Python for testing things and C++ for implementation because it runs faster.

Fuck Java.

Rust maybe someday, once it matures a bit.

You claim that based on what exactly? I do high-performance network packet processing (like 100GBps on a HP ProLian Gen9 server) at my job and we use C++ extensively, STL, templates and OOP including. Implementing the same in pure C would've resulted in failed deadlines, leaked memory and unmaintainable code.

How on earth is C++ high performance?
It doesn't even have restrict.

My man.
Currently I use D almost exclusively. It has a great productivity/performance ratio. Although I am learning Rust as of now.

>Rust maybe someday, once it matures a bit.
Very well said

No shit, Rust is actually strongly typed, unlike C.

> Rust maybe someday, once it matures a bit.
It's just hit 1.17, what are you waiting for exactly?

Not him but it needs a lot more polishing. It's on the right track, may be I'll move to rust after v2 or something

G++ has __restrict tho, but the benefits are negligible anyway. Fun fact, the most performance gain we've had over the O3 performance baseline was by adding __attribute__((always_inline)) to every method called inside the main loop.

Did RLS get pushed into the stable?

> it needs a lot more polishing
This is just a buzzword that means nothing tho.
It's a separate project, it can't be "pushed" into rustc release. Besides, you only need the nightly to compile RLS, after that you can use it with the stable.

user0@primary:~$ cargo install rls
Updating registry `github.com/rust-lang/crates.io-index`
error: could not find `rls` in `registry github.com/rust-lang/crates.io-index`
user0@primary:~$ rustup component add rls
error: toolchain 'stable-x86_64-unknown-linux-gnu' does not contain component 'rls' for target 'x86_64-unknown-linux-gnu'
user0@primary:~$

if c++ is so great why aren't any modern open source text editors written with it?

>if c++ is so great
Your assumptions were flawed from the start.

Made me think

Probably because C++ took away the fun in programming, unlike C

Threadly reminder that dlang-chan is not dead, and she's super duper cute! Say something nice about her, /dpt/!

Clang and VS has it too.

your argument without context is flawed

You have to switch to nightly before adding the components.
[~]$ rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.18.0-nightly (128aa262e 2017-04-28)

[~]$ rustup component add rls
info: downloading component 'rls'
5.9 MiB / 5.9 MiB (100 %) 1.1 MiB/s ETA: 0 s
info: installing component 'rls'
[~]$ rustup component add rust-analysis
info: downloading component 'rust-analysis'
758.0 KiB / 758.0 KiB (100 %) 225.1 KiB/s ETA: 0 s
info: installing component 'rust-analysis'
[~]$ rustup component add rust-src
info: downloading component 'rust-src'
info: installing component 'rust-src'

thanks

you are welcome

Notepad++ is written in C++, it's modern, open source and probably the most popular text editor out there.
Atom and VSCode are built on Electron which is basically Chrome which is written in C++.
Sublime Text is written in C++ too, btw.
What are the other modern text editors you're talking about?

>Sublime Text is written in C++ too, btw.
I thought it was closed source

How are those contradictory?

not sure if troll

How did you check the source?

It is, but I was short on open source modern text editors, there's not a lot of them out there.

My little user can't be this stupid. Can he?

ยป ldd /mnt/Black/Apps/SublimeLinux/sublime_text
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa04101a000)

>t. dumb anime poster

This is the author: news.ycombinator.com/item?id=2822114

Are you implying nothing else can use C++ libraries?

Apparently he can.

javascript and java are super popular, but that does not mean they are not shit
sublime text is the only valid text editor, even if it's closed source

How do I into Prolog?

vim, my friend

>still posting anime
dumb anime poster

first learn to balance a cucumber with your buttocks and walk fast as you can, then go ahead

yeah, vim, I forgot it, even if it's older than me and has not changed a lot in those years
but why change something that works?

Yes? C++ has no standard ABI to begin with and no other language implements C++ FFI to my knowledge, C++ libraries just export C API.

>vim, I forgot it
You say that as if you're not using it right now.

Should I learn smalltalk?

indeed I am using it, just that I was thinking about editors like with tabs and click activity

refer to

The original post was referring to modern editors; so it's understandable.

why?

a) you are an academic faggot
b) you are a hipster faggot who fell for the functional meme

>all recent editors are based on electron
>github
when will we escape the sjw shit?

Reposting from the Rust thread, since people there don't seem to actually it:

At work I program C for Cortex M devices, using a non-userspace RTOS. I was searching for embedded OSes for Rust, and only this one came up: tockos.org/
Has anyone here tried it? It seems board support is pretty lacking.

>tabs and click activity
Vim has buffers, I use them all the time, and can be compiled with mouse support.

Fortran is the choice for high performance applications

When people stop using them; sadly, their popularity creates a vicious cycle.

only if you do physics stuff or simulations, I will never try to do text processing with it

Can we all agree that phyton does not deserve the hate it gets

>sublime
>better than vscode
Funny

I fucking love vim once I spent some time with it; I feel like a god editing text.

Hmm, only three boards. But the project has a potential

Is Javascript /ourtongue/?

Nobody actually uses Rust lmao, that's a giant ycombinator meme

ycombinator by itself is a meme

>mfw i just recently learned that you can just :make

I use Rust tho

Glorious, isn't it?

post rc

Yeah, I find the design of using untrusted capsules (drivers) in the kernel + restricted userland processes interesting. Another way to solve the problem of not having a MMU.

It's just the essentials with nerdtree, syntastic, and pathogen as plugins. I haven't added any keybindings yet because I don't feel the need to yet. If you're still interested, I'll post it.

fuck dlang-chan, we already have dman

>fuck dlang-chan
I want to.

>we already have dman
Why not both?

>Atom and VSCode are built on Electron which is basically Chrome which is written in C++.
retard

>100GBps
Holy shit. 100 giga bytes per second? What the actual fuck.

It's 100 giga-BITS per second, and it's been around for a while now: en.wikipedia.org/wiki/100_Gigabit_Ethernet . The trick it is to process it in real-time on stock x86 servers without ASICs.

Yeah exactly the same rate that Haskell generates garbage!

>It's 100 giga-BITS per second
You clearly said 100 Gigabytes per second.

You wrote GBps, that's why I was shocked. giga-BITS per second is written as Gbps.

Right, my bad.

string manipulation in C

>2017
>not using [[gnu::always_inline]]

Okay, I am the one who posted in the last thread. I asked this because I wanted to benchmark the three languages in my arbitrary criteria: readibility, productivity, and efficiency. I am very surprised at the actual results.
user0@primary:~/devel/proj/test-c$ cat test.c && gcc -O2 test.c && time -p ./a.out
#include

int main()
{
size_t total = 0;
for (int i = 0; i < 100000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

printf("%lu\n", total);
return 0;
}
50085
real 8.15
user 8.15
sys 0.00
user0@primary:~/devel/proj/test-c$

user0@primary:~/devel/proj/test-d$ cat main.d && ldc2 -O2 -release main.d && time -p ./main
import std.stdio;

void main(string[] args)
{
size_t total = 0;
for (int i = 0; i < 100_000; i++)
{
for (int j = 0; j < i; j++)
{
total += (j * j == i) ? j : 0;
}
}

writeln(total);
}
50085
real 7.53
user 7.52
sys 0.00
user0@primary:~/devel/proj/test-d$

user0@primary:~/devel/proj/test-rs/test1/src$ cat main.rs && rustc -O main.rs && time -p ./main
fn main() {
let mut total: i32 = 0i32;
for i in 1..100_001 {
for j in 1..i {
total += if (j*j) == i {j} else {0i32};
}
}
println!("{}", total);
}
50085
real 2.61
user 2.61
sys 0.00
user0@primary:~/devel/proj/test-rs/test1/src$

It's fair to claim that:
1. Abstractions are not causing any negative affect on this test. This is very questionable. Rust claims that it has almost zero cost abstractions. However it turns out to be faster than the equivalent binary produced by GCC/C with -O2 optimizations
2. Interestingly enough, LDC/D has produced faster binaries than C. This is explainable. The GC in its Stdlib has not been triggered and thus it produced native binary that doesn't require garbage collection at all.

I don't hate C and I am new to Rust. But Rust is impressive. What are your thoughts?

what is this? some clang thing?

The problem is so simple, that any benchmarking is meaningless. They all should be in the same ballpark, though.

Where are no abstractions tho, this is a pretty straightforward port. Measure instead, it's idiomatic and it should have the same performance as the naive version.

println!

Rust has a reasonably nice syntax for casting though.

fn main() {
let x :u64 = 7u64 + 3i32 as u64;
let y :f32 = 7i32 as f32 /3f32;
let y :f32 = (7i32/3i32) as f32; // How you cast depends on whether you want float or integer division, if you want the former cast both args.
}

Well, now this makes more sense:
user0@primary:~/devel/proj/test-rs/test1/src$ cat main.rs && rustc -O main.rs && time -p ./main
fn main() {
let total = (1..100000).
map(|i| (0..(i)).filter(|&j| i==j*j).sum::())
.sum::();
println!("{}",total);
}50085
real 5.34
user 5.34
sys 0.00
user0@primary:~/devel/proj/test-rs/test1/src$ cat main.rs && rustc -O main.rs && time -p ./main
fn main() {
let mut total: i32 = 0i32;
for i in 1..100_001 {
for j in 1..i {
total += if (j*j) == i {j} else {0i32};
}
}
println!("{}", total);
}50085
real 2.65
user 2.64
sys 0.00
user0@primary:~/devel/proj/test-rs/test1/src$

The abstraction of map and filter is yielding a slower binary. We haven't been able to make compilers smart enough for functional programming.

Some one post a C++ version of this

this by itself isn't enough to make rust impressive. this is probably some fluke like some compiler optimization that C/GCC and D/GDC are missing. rust on average should be around 1-3x slower than C.

Right, that snippet written in a functional style hides a lot of abstraction. Then again, the same thing is true of a foreach loop over a range.

You're comparing i64 to i32 tho, ofc i32 math is faster.