Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Rust the C replacement

Name: Anonymous 2017-02-07 13:20

http://esr.ibiblio.org/?p=7294&cpage=1
In practice, I found Rust painful to the point of unusability. The learning curve was far worse than I expected; it took me those four days of struggling with inadequate documentation to write 67 lines of wrapper code for the server.

Even things that should be dirt-simple, like string concatenation, are unreasonably difficult. The language demands a huge amount of fussy, obscure ritual before you can get anything done.

The contrast with Go is extreme. By four days in of exploring Go I had mastered most of the language, had a working program and tests, and was adding features to taste.

Name: Anonymous 2017-02-07 17:02

Doesn't Go not have generics?

Name: Anonymous 2017-02-07 18:51

Pike pls

Name: Anonymous 2017-02-07 19:51

The language learning curve is irrelevant in practice as it gets highly amortized the more you use the language. In fact, the amortized cost may even turn negative if the language complexity simplifies using libraries, testing, optimization, improves correctness etc.

Name: Anonymous 2017-02-07 20:23

>>2
`>I want to call a function but I don't know which one I want to call

Generics were a mistake.

Name: Anonymous 2017-02-07 20:44

>>5
Dude, even fucking BASIC had generics.

Name: Anonymous 2017-02-07 21:09

>>5
You ever programming was a mistake.

Name: Anonymous 2017-02-07 21:27

Https://appliedgo.net/generics/

Just reading about the "alternatives" to generics made by gotards makes me laugh. There's not a single viable alternative there but they actually recommend you to simulate generics through hand-rolled shitty code generators. Fucking numbskulls. Just the fact they think there can be any debate about whether generics are necessary shows Go is a language by a retard and for retards.

Name: Anonymous 2017-02-07 21:35

I think Golang should be renamed into Nolang, short for "No Generics Language".

Name: Anonymous 2017-02-08 2:51

>>8
Go is weird. It really seems like its language authors set out to ignore the last 30 years of language research, and succeeded. The first thing I did in a non-trivial program was take a parallel work queue function I'd written and abstract it to handle any type.

I start with this:

WorkInParallel(items []Foo, workOnItem func(f Foo) {
// work on f
})


But I need to be able to call it with []Bar too. Well I can't do the obvious and write something like WorkInParallel<T>(items []T, workOnItem func(t T)) because no generics. Fine, I'll just use the unspecified type and force the callers to cast.

var bs []Bar = ...

WorkInParallel(bs, func(i interface{}) {
b, _ = i.(Bar)
// do the actual work
})


That looks like shit, but at least it works. Oh wait, no it doesn't:

cannot use bs (type []Bar) as type []interface {} in argument to WorkInParallel

Well I'll just cast bs to a slice of interf--

invalid type assertion: bs.([]<inter>) (non-interface type []Bar on left)

OK FINE

var bs []Bar = ...

is := make([]interface{}, len(bs))
for i, b := range bs {
is[i] = b
}

WorkInParallel(is, func(i interface{}) {
b, _ := i.(Bar)
// do the actual work
})


What the fuck??

I'm not saying I completely dislike Go. It's reasonably performant, easy to write and doesn't have too much baggage. It feels more structural than object-oriented, which is nice. I even think that design decisions based on subjective factors are defensible.

But what I can't stand is Go zealots pretending there's some grand strategy behind the language's quirks other than "Ken/Rob didn't like that feature". There is no method to this madness.

Name: Donald Trump 2017-02-08 3:27

Check 'Em.

Name: Anonymous 2017-02-08 4:06

>>11
Awesome dubs, Mr. President.

Name: Anonymous 2017-02-08 6:09

Daily reminder that even C has generics in form of _Generic macro which selects overload of function/macro based on compile-time type.

Name: Anonymous 2017-02-08 21:28

>>13
Or you could just use tagged unions like a normal person, rather than reinventing the wheel.

Name: Anonymous 2017-02-08 21:50

C replacement? It's been with us awhile now, and it's called C++.

Name: Anonymous 2017-02-08 23:40

>>15
sage

Name: Anonymous 2017-02-09 7:42

>>16
yes this is a sage post very wise

Name: Anonymous 2017-02-09 8:05

>>15
IHBT

Name: Rustafarians Unite! 2017-02-09 10:02

Rustafarians Unite!

Name: Anonymous 2017-02-09 12:08

Name: Anonymous 2017-02-10 6:17

Found something else. Let's take a look at cat(1)

Here's a big list, except for sbase's and acu's: https://gist.github.com/pete/665971
The Suckless version from sbase: http://git.suckless.org/sbase/tree/cat.c

Now, GNU and BSD's version of cat are bloated, sure. But take a look at cat re-implemented in Rust.

https://github.com/uutils/coreutils/blob/master/src/cat/cat.rs

Look at home many people are contributing to the project. They're already campaigning in typical marxist fashion for distros to use it instead of GNU Core Utils, claiming it's more secure and faster and that it's the future.

Name: Anonymous 2017-02-10 8:00

>>21
Its faster because putc/getc are slow.
Try to read()/write() with custom buffer

Name: Anonymous 2017-02-10 9:46

>>22
but many C cat implementations don't use putc/getc. see plan9

Name: Cudder !cXCudderUE 2017-02-10 11:37

>>21
Look at the binary sizes for even more sense of bloat.

>>22
It also takes over the cache with its elephantine size, making everything else on the system slower. These benchmarks are stupid and the reason for things like 4-kilobyte memcpy() implementations.

>>23
Most don't. Suckless is one of the exceptions.

Name: Cudder !cXCudderUE 2017-02-10 12:10

I'm gay!

Name: Anonymous 2017-02-10 14:24

>>25
fuck off fake cudder

Name: Anonymous 2017-02-10 14:53

>>21
Incredible. Rust has all the inefficiencies of a scripting language, except you actually have to type them out yourself instead of the runtime inserting them automatically.

Name: Anonymous 2017-02-10 22:45

>>21
This smells like a dead striped Polecat /kebabs/, not like a cat.

I also remember that the echo implementation of GNU as well as the original echo for unix both could handle out of memory situations unlike the plan9 echo that needed to allocate a whole buffer and crashed otherwise.

Name: Anonymous 2017-02-10 23:50

>>28
the original echo for unix both could handle out of memory situations

What's the point of handling OOM if your program's only job is to send the input to stdout? What is it going to do, keep running? Might as well crash.

Of course if plan9 is doing something insane like buffering the entire input, then yeah they're idiots.

Name: Anonymous 2017-02-11 0:43

>>29
Why should it crash when it doesn't have to? Sure, running unbuffered will be slow as balls, but for forensic sys admin slow is better than nothing.

Name: Cudder !cXCudderUE 2017-02-11 17:09

>>28-30
The real question is why the fuck does echo even need to dynamically allocate memory? Its only job is to print argv, which has already been allocated by the kernel. If there's no memory for argv there's no chance the process can even start.

Name: b00mheadsh0t@hotmail.com 2017-02-11 17:17

>>31
cudder man, where can i find some of your source code repos?

Name: Anonymous 2017-02-11 17:39

>>31
what about echoing a stream though

u need to allocate a buffer to hold each chunk

or you can do it 1 byte at a time but that's not efficient

Name: Anonymous 2017-02-11 20:11

>>32
``open source" is a codeword for bloat

Name: Anonymous 2017-02-11 21:24

C CONSIDERD HARMFULL AND RUST TOO!!! ALL COMPUTER VIRUS ARE CREATED WITH C SCIENCE COMPUTERS RUST MAKES MORE VIRUS!! IM COMPUTER SCIENCE HASKELL USE HASKELL PROTECT

Name: Anonymous 2017-02-11 23:46

>>35
The Hasklel runtime is written in C. Use a self-hosting lambda calculus interpreter instead.

Name: Cudder !cXCudderUE 2017-02-12 0:57

>>33
What do you mean "echoing a stream" --- the echo command echoes argv and nothing else. (Unless GNU decided their bloatutils version would...?)

Name: Anonymous 2017-02-12 2:41

Name: Anonymous 2017-02-12 4:02

>>38
probably to make the program 'faster' by doing only one io syscall. (it's retarded and they shouldn't)

Name: Anonymous 2017-02-12 4:21

>>38
Because write is orders of a magnitude slower, especially when writing to regular old disk drives.

Name: Anonymous 2017-02-12 5:51

write my anus

Name: Anonymous 2017-02-12 14:00

:stopmusic:

Name: Anonymous 2017-02-12 17:13

>>40
It doesn't fall back to unbuffered printing if malloc falls however.
Good luck trying to echo an 1GB string this way.

Name: Anonymous 2017-02-12 17:17

CHECK'EM MOTHERFUCKERS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SIEG HEIL!!!!!!

Name: Steve 2017-02-12 17:26

>>44
nooooooooooooooo!

Name: Anonymous 2017-02-12 20:53

>>31

It's because the plan9 people wanted it only to write once, because when doing lots of echo's over network filesystems, that would get very slow quickly.

Name: Cudder !cXCudderUE 2017-02-14 2:53

>>46
Apparently they've never heard of caching?

Name: Anonymous 2017-02-14 7:37

>>47
Caching is bloat

Name: Anonymous 2017-02-14 8:45

>>48
Nope. Caching is the #1 performance enhancing algorithm.
Your CPU has 3 levels of caches. OS has disk read/write caches, your IO library has cache buffers, your browser stores render pages in cache, Cache servers store static copies of websites to get the downloads faster. Caching is everywhere, even your desk is a cache of all important items in the room.

Name: Anonymous 2017-02-14 12:56

>>49
How bloated! All that redundant data taking up space!

Name: Anonymous 2017-02-14 15:27

>>49
But write(2) doesn't have cache buffers, right? Wouldn't you have to split the data into buffers small enough to fit into the fast CPU cache to take advantage of it?

Name: Anonymous 2017-02-14 16:14

Programming for me is like a religion. And Rust is the shit.

Name: Anonymous 2017-02-14 16:21

>>51
write doesn't need cache buffers, its for writing big files down.
fwrite is only faster when you have random small chunks of data getting written to disk.
fwrite
A.fills buffer with data.
B.writes the buffer to stream when if full (flush)
(https://www.gnu.org/software/libc/manual/html_node/Controlling-Buffering.html can be disabled)
write
A.Just sends the data to IO system of kernel

Name: Anonymous 2017-02-14 17:56

>>38,46
Pipes on plan9 preserve write boundaries, so they may have written it like that to ensure that every echo is a "packet". Not sure who would ever want to rely on the write semantics of echo(1) though, not that this behavior is documented to begin with... http://man.cat-v.org/plan_9/1/echo

>>47
How safely CAN you cache writes over a network though? Blocking reads are often used for synchronization, so a program can cease to be correct if a write to it is only delivered when the network stack feels like it.

Name: Steve 2017-02-14 18:03

I claim these dubs in the name of the LORD

"Come to me, all you who are weary and burdened, and I will give you rest."

Matthew 11:28

Name: Anonymous 2017-02-15 0:37

ori_b 723 days ago [-]
Note that the plan9 version does some extra work so that it can send the entire buffer in one write() operation. This is because Plan 9 guarantees that messages smaller than the size of a pipe buffer are sent as an atomic write, given a sufficiently large recieve buffer on the other end.
This simplifies quite a bit of code that reads and writes commands into ctl files.

lallysingh 723 days ago [-]
Why copy it all instead of writev()?

ori_b 723 days ago [-]
http://plan9.bell-labs.com/sources/plan9/sys/src/libc/9sys/writev.c
In other words, writev on plan9 isn't a system call -- it does the same copying that echo.c does. Also, echo.c probably predates writev.c.

Don't change these.
Name: Email:
Entire Thread Thread List