News for hackers. Stuff that matters.
Re:Tor in a safer language: Network team update from Amsterdam by eternalban on Saturday April 01, 2017 @03:43PM (#14013772)
Re:Tor in a safer language: Network team update from Amsterdam by twic on Saturday April 01, 2017 @04:27PM (#14014006)
I looked into Ada last year. Getting a toolchain working sanely on a Mac seemed quite a lot of work; it's not in Homebrew, the MacPorts version has some weird bootstrap process, and the various random versions available for download had a murky mix of license and implementation issues that i don't remember in detail.

So i read documentation instead. Ada mostly seems like a pretty sensible language. Its story on memory safety, though, seems to be "don't use dynamically allocated memory", or at least, if you do, you're on your own. It doesn't have anything like Rust's safety guarantees, or those that fall out of having a garbage collector.

If it was 2007, and Ada was a bit more easily available, I'd be agitating for it. But i think its shot at the open source big time has passed.

Re:Tor in a safer language: Network team update from Amsterdam by twic on Saturday April 01, 2017 @07:26PM (#14014758)
Someone left a comment mentioning that i could download a compiler from AdaCore, but seems to have deleted it. I was going to thank them! AdaCore's website is not very helpful, but googling turned up:

http://libre.adacore.com/download/

You can download the 'GPL edition' of GNAT [1]. This is a complete toolchain for Ada 2005, with the same actual compiler as the commercial version, i think. The libraries are GPL'd, so if you distribute a binary built with it, it has to be GPL'd. So, no Ada 2012, and no way to distribute binaries willy-nilly, but certainly enough to explore the language.

[1] http://libre.adacore.com/tools/gnat-gpl-edition/faq/

Re:Tor in a safer language: Network team update from Amsterdam by fpoling on Sunday April 02, 2017 @06:00AM (#14016617)
Ada allows to return from a function a stack-allocated array of runtime-dependent size. This alone removes wast number of cases when one needs to allocate memory dynamicalky in C/C++.

I always puzzled why even C++ does not provide any facilities like that out of the box.

Re:Tor in a safer language: Network team update from Amsterdam by jeffdavis on Saturday April 01, 2017 @08:53PM (#14015067)
(1) Better explanations about how to live without heap allocations or how to use them effectively in Ada. It feels like unchecked_deallocate is wrong, but then I don't really see explanations about what programmers should do instead.

(2) Compiler and runtime licenses. I always feel like the version of Ada I get is either somehow not the "best" one or has some lingering license issue with the runtime library. I don't think this is necessarily true, but it's easy to get that impression.

(3) Packaging, libraries, and documentation. Many developers expect a tool like cargo to be available and have access to a wide variety of open-source libraries. They also expect lots of tutorial documentation and blogs.

Re:Tor in a safer language: Network team update from Amsterdam by pjmlp on Sunday April 02, 2017 @02:47AM (#14016185)
I advise you to watch this presentation.

"Memory Management with Ada 2012"

https://archive.fosdem.org/2016/schedule/event/ada_memory/

Re:Tor in a safer language: Network team update from Amsterdam by jeffdavis on Tuesday April 04, 2017 @06:06PM (#14037683)
Thank you, very educational!
Re:Tor in a safer language: Network team update from Amsterdam by SomeStupidPoint on Saturday April 01, 2017 @03:58PM (#14013845)
I mean, isn't SPARK basically meant for high assurance things (like Tor should be)?
Re:Tor in a safer language: Network team update from Amsterdam by nickpsecurity on Saturday April 01, 2017 @04:18PM (#14013951)
Re:Tor in a safer language: Network team update from Amsterdam by eternalban on Saturday April 01, 2017 @04:08PM (#14013896)
& considering that Naval Research Laboratory gifted us with Tor it is surprising it wasn't written in Ada to begin with.
Re:Tor in a safer language: Network team update from Amsterdam by bluejekyll on Saturday April 01, 2017 @03:59PM (#14013852)
1) Two words: "begin" and "end";

2) Unix, C is so fundamental to building software, that I think any language that doesn't share syntax with it is doomed. Having a common syntax helps in learning new languages, IMO, and can also be a launching point for differing semantics...

Re:Tor in a safer language: Network team update from Amsterdam by nickpsecurity on Saturday April 01, 2017 @04:16PM (#14013936)
I'll give you it's overly verbose even though quite a bit of it was justifiable. The theory of Ada's designers was that people read software more than write it. So, the syntax should be designed to facilitate catching errors in maintenance mode, during extensions, or during integrations. It's done phenomenal at that per industrial, case studies despite having been invented in the 80's when lots of language decisions were still being debated.

EDIT: I keep thinking a different language that acts as a front end w/ a better syntax might be a good idea. It outputs Ada that integrates with the tooling ecosystem. Also, a seemless FFI for C libraries like Julia's.

Re:Tor in a safer language: Network team update from Amsterdam by socmag on Saturday April 01, 2017 @06:11PM (#14014463)
I totally agree that code should be written to be read.

It certainly wouldn't hurt if people simply used a more literate programming style no matter what language they choose

Far too many people think code as below is acceptable.

This is C obviously, but pretty much equal horrors around in every language.

This isn't 1994 and the compiler really doesn't care how long your variable names are, plus EatWhite() is pretty damn fast.

  const int to_pn  = base_n ^ label_n;
      const int from_p = _array[to_pn].check;
      const int base_p = _array[from_p].base ();
      const bool flag
        = _consult (base_n, base_p, _ninfo[from_n].child, _ninfo[from_p].child);
      uchar child[256];
      uchar* const first = &child[0];
      uchar* const last  = flag ? _set_child (first, base_n, _ninfo[from_n].child, label_n)
        : _set_child (first, base_p, _ninfo
Re:Tor in a safer language: Network team update from Amsterdam by wott on Saturday April 01, 2017 @09:22PM (#14015175)
> This is C obviously

No, that's C++.

Re:Tor in a safer language: Network team update from Amsterdam by __david__ on Saturday April 01, 2017 @11:02PM (#14015527)
You can't say that definitively based on that code. It could very well be C code. There's nothing there syntactically that a straight C compiler would barf on.
Re:Tor in a safer language: Network team update from Amsterdam by socmag on Monday April 03, 2017 @05:29AM (#14021569)
Absolutely correct.
Re:Tor in a safer language: Network team update from Amsterdam by smitherfield on Sunday April 02, 2017 @02:35AM (#14016149)
It could be C if `_array` is an array of

  struct {
          int check;
          int (*base)(void);
  };
Re:Tor in a safer language: Network team update from Amsterdam by socmag on Monday April 03, 2017 @05:27AM (#14021559)
It is!
Re:Tor in a safer language: Network team update from Amsterdam by socmag on Monday April 03, 2017 @05:28AM (#14021566)
It is C.
Re:Tor in a safer language: Network team update from Amsterdam by bluejekyll on Saturday April 01, 2017 @05:15PM (#14014230)
> I keep thinking a different language that acts as a front end w/ a better syntax might be a good idea... Also, a seemless FFI for C libraries like Julia's.

You mean Rust I think ;)

Re:Tor in a safer language: Network team update from Amsterdam by nickpsecurity on Saturday April 01, 2017 @07:01PM (#14014653)
People have had a hard time learning Rust. I also get gripes about its inconsistency in language syntax. The FFI I hear is good. It certainly doesn't output to SPARK or a C subset designed for easy, static analysis.

So, Rust ain't the Ada makeover Im thinking about. It's also in a stability-oriented freeze of existing design right now. So, the makeover will need to be a different language.

Re:Tor in a safer language: Network team update from Amsterdam by bluejekyll on Sunday April 02, 2017 @01:00AM (#14015870)
> People have had a hard time learning Rust.

I won't lie to you. It took me longer to produce good code in Rust than almost any other language I've recently learned. But it's worth it; it's quite simply amazing that it is capable of guaranteeing what it does, with nearly zero overhead. Also, I'd say in many ways it's simpler than C, because it has no undefined behavior; I don't need to concern myself with any of the nuances that I had to learn in C. I highly encourage you to give it two weeks, that's what it took me to become hooked.

Re:Tor in a safer language: Network team update from Amsterdam by eternalban on Saturday April 01, 2017 @08:38PM (#14015024)
That type system is pretty sophisticated. You could probably slap a FP front-end ala Haskell but that would hardly make it more accessible. Might as well just bite the bullet and learn the language.
Re:Tor in a safer language: Network team update from Amsterdam by kbenson on Saturday April 01, 2017 @06:35PM (#14014547)
Regarding #2, there's definitely a penalty a language pays for not following C-like syntax and semantics, as people consider it "harder" to learn, because people generally discount the time they've already put into learning similar languages when considering how easy a language is to learn. I suspect someone that knows Lisp but not C might find Clojure easier to learn than Rust, or even Python. The less software in use written in C, the less fundamental it is.

There's also a penalty a language pays for following a C-like syntax and semantics but diverging in specific but significant ways. In this category, I present Perl, which much of whole generation of users decided to treat like C, and got very confused and upset when it didn't always behave like they expected (which I maintain is because they didn't actually understand the language as well as they thought). There's a penalty for being very like something else to the point that people can mostly ignore the differences, but occasionally those differences come out to bite them if they haven't actually learned what they are.

Re:Tor in a safer language: Network team update from Amsterdam by RandomOpinion on Saturday April 01, 2017 @04:10PM (#14013903)
"BEGIN" and "END" aren't all that bad. Some of us got our start in software using Turbo Pascal long, long ago.
Re:Tor in a safer language: Network team update from Amsterdam by scott_karana on Saturday April 01, 2017 @04:15PM (#14013931)
"End" didn't stop Ruby from taking off... admittedly a different crowd.
Re:Tor in a safer language: Network team update from Amsterdam by bitwize on Saturday April 01, 2017 @03:57PM (#14013838)
+1 for Ada. Rust is basically hipster-compatible Ada, which explains why Rust will be adopted and Ada will not.
Re:Tor in a safer language: Network team update from Amsterdam by the_mitsuhiko on Saturday April 01, 2017 @04:18PM (#14013949)
Repeating this nonsense won't make it any more correct.