Live data from Hacker News

Writing a website in Rust

blog.viraptor.info

131–140 of 141 posts

Re: Writing a website in Rust

#131

Earlier quoted context omitted.

Not in Rust 1.0. In the nightlies there are syntax extensions available that give you more power, but those are likely to see significant revisions before they're available in a stable version since they're a major backwards compatibility hazard.

Who's working on this? I may have something to contribute in this direction.

I'm not sure who specifically is working on improving the macro system, but it's definitely something that's been prioritized. My primary recommendation for contacting the relevant people would be either the Rust internals forums (https://internals.rust-lang.org) or the #rust-internals channel on irc.mozilla.org.

Re: Writing a website in Rust

#132

Earlier quoted context omitted.

If you're going to write a block of text like that, you could at least fact check the main premise. Rust had GC. They started off with GC, so it wasn't the very first decision that "no code can perform with garbage collection". Here's a post about removing GC from core rust 2 years ago: http://pcwalton.github.io/blog/2013/06/02/removing-garbage-c... Next: they didn't kill GC. They removed it from core, because rust i…

Rc and Arc aren't exactly GC types... they are just reference-counted pointers, Rc being akin to C++'s shared_ptr. I get that in a sense, this is garbage collection, but certainly not full-featured like the ones you find in other languages.

Nim's GC uses reference counting, so I'd say it's a least a fair comparison: http://nim-lang.org/docs/gc.html

Re: Writing a website in Rust

#133

Earlier quoted context omitted.

That's kinda what I was thinking when I commented, and there are sure to be exceptions. But I don't see anything different with your Snabb switch example. You can probably use Java and JNI for that matter to call mmap, but would you be able to write an implementation of mmap in LuaJIT ?

Yes you can call mmap with the ffi in LuaJIT just fine. It is not very complicated, it just asks the kernel to do it. Implementing what the kernel does, well that does need some assembly.

Indeed we agree. Using any ffi for that matter.

Re: Writing a website in Rust

#134

Earlier quoted context omitted.

Out of curiosity (I've never done systems programming), what are some of the things that make a language more suited to systems programming rather than web (other than libraries and community support - I'm more interested in the intrinsic qualities of the language)?

I think seriously the intrinsic thing is that the language itself doesn't marshal (right word, not sure) anything that's particularly fat. The classic is if allocating memory require dealing with a general purpose garbage collector. If that's the case you're pretty much dead as far as systems stuff goes because now you can't predict how long anything will take to run. And the minimal libraries usually need to be ligh…

> If that's the case you're pretty much dead as far as systems stuff goes because now you can't predict how long anything will take to run.

Erlang would argue with you. GC works fine as long as you have a bunch of really tiny heaps (attached to a bunch of really tiny processes) which can be collected in parallel. It just sucks for Unix-process-sized heaps.

Re: Writing a website in Rust

#135

Earlier quoted context omitted.

Not in Rust 1.0. In the nightlies there are syntax extensions available that give you more power, but those are likely to see significant revisions before they're available in a stable version since they're a major backwards compatibility hazard.

Who's working on this? I may have something to contribute in this direction.

Not something being actively worked on, but I and some others care about it.

Rust macro-esque things are of three types:

- Macro by Example (MBE): These are easily defined by the user via `macro_rules!`, which can match on their input and expand to some output at compile time. These don't need to be defined as a plugin; you can define a macro directly in your code.

- tokentree expansion plugins: These take in a token tree, run arbitrary code, and output an AST (syntax tree) node. Ish.

- AST expansion plugin: These take in the parsed AST, run arbitrary code, and output another AST to replace or augment it.

There also is support for custom lints and llvm passes.

All of this is at compile time.

Re: Writing a website in Rust

#136
post #127

Earlier quoted context omitted.

http://erickt.github.io/blog/2014/12/13/performance-digressi...

How about some measurements made with rustc 1.0.0? (There seem to have been plenty of breaking language changes in the last 6 months.)

http://xania.org/201505/on-rust-performance

(The "faster" bit isn't important; various reasons might have made C++ slower than Rust for this, but what is important is that perf was comparable)

Re: Writing a website in Rust

#137

Well, IMHO, "the right hammer for the right nail". Rust is a great systems language (besides the lack of bitfields) but I wouldn't use it as a web language. Just as much as I wouldn't use C++ to develop webapps. Sure you can do it but then again there are far easier ways to achieve your goal.

I think I saw an article about people using c++14 as a scripting language since infered type, closures and other syntax niceties can make simple c++ as short as python.

"As short as" doesn't necessarily mean "can be written as quickly as". I write a lot of C++ at work, and it's usually quicker to write a Python script to do glue type work.

There is another advantage - I mostly write python for the 'glue' scripts in large build systems. It saves some complication if your build system doesn't first have to compile chunks of itself!

Re: Writing a website in Rust

#139

Earlier quoted context omitted.

Who's working on this? I may have something to contribute in this direction.

Not something being actively worked on, but I and some others care about it. Rust macro-esque things are of three types: - Macro by Example (MBE): These are easily defined by the user via `macro_rules!`, which can match on their input and expand to some output at compile time. These don't need to be defined as a plugin; you can define a macro directly in your code. - tokentree expansion plugins: These take in a token…

I'm not sure what a token tree is. Usually compilers feed a token list to the parser, which then generates an AST. The AST is what compile-time meta-programming such as macro expansion works on.

In fully-blown compile-time meta-programming systems such as Converge or Template Haskell, the "AST expansion plugin" can and typically does itself invoke the compiler to compile arbitrary code which in turn outputs a new AST for further compilation.

I'm not fully sure what macro-by-example is.

Re: Writing a website in Rust

#140

Earlier quoted context omitted.

I think I saw an article about people using c++14 as a scripting language since infered type, closures and other syntax niceties can make simple c++ as short as python.

"As short as" doesn't necessarily mean "can be written as quickly as". I write a lot of C++ at work, and it's usually quicker to write a Python script to do glue type work. There is another advantage - I mostly write python for the 'glue' scripts in large build systems. It saves some complication if your build system doesn't first have to compile chunks of itself!

> "As short as" doesn't necessarily mean "can be written as quickly as".

Meaning, c++ semantics still require more care to have a running program, even a low-LoC one ?

Post reply on HN