News for hackers. Stuff that matters.
Re:Computer Language Benchmarks Game – Rust vs. Go by shanemhansen on Tuesday December 23, 2014 @09:48PM (#8791334)
Please illuminate me as to how you have arrived at the conclusion go is a scripting language. It doesn't check any of the scripting language boxes I've ever heard of.
Re:Computer Language Benchmarks Game – Rust vs. Go by jerf on Tuesday December 23, 2014 @10:16PM (#8791394)
"It doesn't check any of the scripting language boxes I've ever heard of."

Well, as I sort of implied but will now spell out, the 1990s produced a certain stereotypical definition of a "scripting language" that I think is ultimately overspecified. A 1990s scripting language is extremely dynamic, including the type system, everything's boxed, everything's a hash table of one form or another, and in general everything converges to produce a language that is very fluid, but ultimately very slow. These were overreactions to the languages of the day, which were, I think, easy to forget how hard they were to use in practice. Even when you use C or C++ today, you're still using it with radically better community best practices, libraries, and better tool support. 1990s C++ was some hard stuff to work with even before you let threading in. Into that world, Perl and Python were a breath of fresh air!

It is easy to get deceived by the constant stream of benchmarks that are 50% faster than last month and the constant stream of incredibly-micro micro-benchmarks where JS or something is as fast as C at adding together small integers in an array or something. The reality is that after years and years and years of work, they're fundamentally slow. Yes, even Javascript; remember, for asm.js to produce such fantastic speedups, Javascript must be leaving that much performance on the table.

Go ends up in practice working very like a scripting language; line counts are virtually identical in my experience, logic is very similar, and the fluidity is there, partially by virtue of ignoring the very things that Rust brings out and makes explicit (the ownership and such). I can't say with a straight face that the logic comes out the same, the way a Perl program can be virtually transliterated into Python, because the ability to use concurrency seriously means that you don't have to bend into the contortions you sometimes do to simulate it in those older languages, but otherwise it works similarly, except that you use structs and interfaces instead.

Scripting 1.0, being made when this world was younger and 150MHz was a fast machine, made some mistakes in thinking that compilers would eventually be able to overcome their fundamental weaknesses. It was a neat experiment to make everything wildly dynamic, but in the end, you end up paying and paying and paying and paying and paying for that dynamism, but you only use it rarely. You may be inclined to object, saying "I use it all the time! I use Ruby gems to assemble all sorts of complicated and interesting objects!", but that's because we humans are really bad at order of magnitudes inside of programs... you set up your objects essentially once at the "beginning" of some computation, then you pay for that dynamism billions of times. You pay for the awesome exception handling all the time, yet only use it rarely. You pay... etc.

Scripting 1.0 also accidentally interpreted the failures of the languages of the day, which were all statically typed, as being significantly caused by static typing. I'd suggest we've since learned that the static typing of the time was simply bad; the languages are not all that great, and the ways they were used even worse (inheritance favored over composition, etc.). So they whiplashed wildly to the opposite, which turns out to have been an overreaction similar to the previous paragraphs. You pay for all that typing dynamism all the time, yet in practice, legal inputs to a given function are characterized by a limited number of types, legal outputs also, and all this dynamism is really going to waste. (Go's interfaces capture %95 of the use cases here while still being perfectly statically typed. There are other possibilities as well for other languages to explore.)

Scripting 2.0 is fixing that problem by creating languages that judiciously use dynamism instead of indiscriminately slathering it everywhere, that are merely somewhat slower than C rather than the night-and-day of 1.0, are still fairly easy to program in even if they are not as wildly dynamic, and execute an order of magnitude faster than Python or Perl or JS while also obtaining the advantages of more static typing for software quality. Go is merely the most prominent of this line of language, there's a whole bunch of them bubbling up right now. Julia is trying to fit into this for numeric computing, LuaJIT is sitting there sipping the punch wondering why all the other languages are so many years late to the party, there's another language that's popped up on HN every so often in the past few months that fits in here but escapes my mind, and I think we're going to see more of this. With computer processors speeds having stalled it becomes a difficult proposition to go up to a programmer and promise them the moon, and all they have to do is be willing to be 20-100x slower than the competition, and, uh, well, no, you won't just catch up in 5 years of processor advancement because raw clock speeds are stalled.

So I find in practice Go is a Scripting 2.0 language. You write it at roughly Python speeds, it runs much faster and works much better in the cloud where that actually matters, and part of the way it accomplishes this is to do things like gloss over memory management details and exactly how interfaces are satisfied (dynamic lookup at runtime, compare with wycat's comments in the thread on how Rust does it), and generally focuses on being relatively easy and fast to write. Looking at it from another direction, compare Go to Rust and Go looks more like a scripting language than a competitor to Rust.

I could write a similar post on how Rust is also a harbinger of a new wave of languages that are trying to replace C++, but make it easier to write correct code than to write incorrect code. (C++, alas, makes both quite easy, and makes it hard to tell which is which. It is true that correct code is possible, but it takes more skill to get there than it should.) Nim, for instance, fits into this mold, though a great deal less popular. I expect more. The dependent type community is also struggling mightily in the direction of putting this sort of thing out, and I wouldn't be surprised to see something moderately practical pop out in about 5 years or so.

I know the narrative right now is that Rust and Go are in some sort of fierce competition, but personally I see a world where they live in harmony, with a great deal less overlap than most people currently see, just as Python would still not displace C even if it were in fact 25 times faster.

It's really quite an exciting time and I can't wait to get my hands on these languages. I am ready to leave C and C++ behind. Of course I've already got Go in hand, but I look forward to Rust. (As I am personally a "cutting edge" but not a "bleeding edge" sort of guy in language choice, Rust and I are not yet a match. I consider this just a matter of time.)

All just my opinion, of course. I am not the keeper of the term "scripting language." YMMV.

Re:Computer Language Benchmarks Game – Rust vs. Go by codexon on Tuesday December 23, 2014 @11:40PM (#8791561)
Go actually has large line counts closer to Java and C due to lack of generics and exceptions, and the need to specify structs.

http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

http://benchmarksgame.alioth.debian.org/u64q/go.html

Re:Computer Language Benchmarks Game – Rust vs. Go by jerf on Wednesday December 24, 2014 @12:02AM (#8791614)
On the benchmarks, sure. That wouldn't surprise me. In my real code, though, it writes like well-written Python, minus an occasional penalty for a list comprehension or something, which I don't really use that often anyhow.

If you want to play Perl golf, Perl will blow it away. Then again, my well-written Perl and Go come out pretty similarly.

Re:Computer Language Benchmarks Game – Rust vs. Go by Retra on Tuesday December 23, 2014 @10:51PM (#8791468)
You don't think that a scripting language is just a language for writing scripts -- environment-specific interpreted code?

I don't see how inventing terms like "scripting 2.0" makes anything clearer. It just reeks of unjustifiable rationalization and square-peg-round-hole thinking.

Re:Computer Language Benchmarks Game – Rust vs. Go by dcposch on Tuesday December 23, 2014 @11:51PM (#8791592)
I agree with most of what you said, but Go is not a scripting language. The defining characteristic of scripts is that they are interpreted. Go compiles ahead of time to a statically linked binary.
Re:Computer Language Benchmarks Game – Rust vs. Go by jerf on Wednesday December 24, 2014 @12:04AM (#8791621)
"Scripts are interpreted" is a bit 1990s; as the Scripting 1.0 languages have tried to squeeze every last bit of performance out of the constraints they labor under this is less true than it used to be. And more to the point, rather than a binary distinction like you could have claimed in 1995, it's much, much more a continuum now, and with computers running a bazillion times faster, much less important. I'm not that worried about applying a useless criterion to languages that dates from an era whose desktop computers would aspire to keep up with a low-end 'feature' phone.
Re:Computer Language Benchmarks Game – Rust vs. Go by laumars on Wednesday December 24, 2014 @06:01AM (#8792411)
I think the former poster meant that scripts are JIT compiled rather than interpreted. But either way, with scripting languages, you redistribute the source code. With AOT compiled languages such as Go and Rust, you redistribute the binary (albeit some will always prefer to compile on the target PC).

That's not to say that I think Go and Rust are the same classification of languages though. I think "scripting vs compiled" is an overly simplistic view. Go compares better against the byte-code AOT compiled languages such as C# and Java. These kind of languages are also seen in some traditionally scripting-dominated markets (eg web development) while still being used as systems languages as well.

Re:Computer Language Benchmarks Game – Rust vs. Go by Xixi on Wednesday December 24, 2014 @01:08AM (#8791796)
Scripting language doesn't imply at all "interpreted". Otherwise you would just say that: interpreted. "Scripting language" denotes a strong tie between a system and the language used to script it. In other words you will often have to use a given scripting language because it is the interface to the system you want to script. We should really always say: "scripting language of X".

"Fortran and Cobol were the scripting languages of early IBM mainframes. C was the scripting language of Unix, and so, later, was Perl. Tcl is the scripting language of Tk. Java and Javascript are intended to be the scripting languages of web browsers." (from Being popular, http://www.paulgraham.com/popular.html)

Re:Computer Language Benchmarks Game – Rust vs. Go by Cyther606 on Wednesday December 24, 2014 @12:13AM (#8791644)
> escapes my mind

Love the post. Were you thinking of Nim [1]? It recently benchmarked close to C++ in speed [2] and it will assuredly continue gaining ground.

    import rdstdin, strutils

    let
      time24 = readLineFromStdin("Enter a 24-hour time: ").split(':').map(parseInt)
      hours24 = time24[0]
      minutes24 = time24[1]
      flights: array[8, tuple[since: int,
                              depart: string,
                              arrive: string]] = [(480, "8:00 a.m.", "10:16 a.m."),
                                                  (583, "9:43 a.m.", "11:52 a.m."),
                                                  (679, "11:19 a.m.", "1:31 p.m."),
                                                  (767, "12:47 p.m.", "3:00 p.m."),
                                                  (840, "2:00 p.m.", "4:08 p.m."),
                                                  (945, "3:45 p.m.", "5:55 p.m."),
                                                  (1140, "7:00 p.m.", "9:20 p.m."),
                                                  (1305, "9:45 p.m.", "11:58 p.m.")]

    proc minutesSinceMidnight(hours: int = hours24, minutes: int = minutes24): int =
      hours * 60 + minutes

    proc cmpFlights(m = minutesSinceMidnight()): seq[int] =
      result = newSeq[int](flights.len)
      for i in 0 .. <flights.len:
        result[i] = abs(m - flights[i].since)

    proc getClosest(): int =
      for k,v in cmpFlights():
        if v == cmpFlights().min: return k

    echo "Closest departure time is ", flights[getClosest()].depart,
      ", arriving at ", flights[getClosest()].arrive
[1] https://github.com/Araq/Nimrod/wiki/Nimrod-for-C-programmers

[2]: https://www.reddit.com/r/programming/comments/2pvf68/armv7_v...

Re:Computer Language Benchmarks Game – Rust vs. Go by Thaxll on Tuesday December 23, 2014 @10:18PM (#8791398)
Lot of text for almost nothing, sorry but Go isn't a scripting language.

You can't call a language that is compiled, GC'ed, statically-typed, good concurrency model a 'scripting language'.

Re:Computer Language Benchmarks Game – Rust vs. Go by shadowmint on Tuesday December 23, 2014 @10:37PM (#8791433)
Depends what you define a 'scripting language' as, doesn't it?

Some people argue python isn't a scripting language, because it 'compiles' to byte code.

What is the defining characteristic of a scripting language for you?

That it runs in an interpreter? That you distribute source code files that are executed by a monolithic binary? That you can't compile it into a static binary?

java, lua, javascript, perl, python, make, awk, powershell?

Which of these doesn't tick at least one of those?

The point the parent post is making is that 'scripting language' is an arbitrary term that isn't well defined. It tends to traditionally mean "relatively easy to code in language that runs slowly and has a horrible syntax". ie. bash scripts, perl scripts, make files and the like.

...but technically speaking, what makes these 'scripting languages' as distinct from other languages, like say, java? Or, indeed, go?

The parent isn't arguing that go is a scripting language (I wouldn't say that either), but that it shares some common features, both good and bad (ease of writing, gc) with some other 'scripting languages'.

Re:Computer Language Benchmarks Game – Rust vs. Go by jerf on Wednesday December 24, 2014 @12:10AM (#8791635)
"but that it shares some common features, both good and bad (ease of writing, gc) with some other 'scripting languages'."

And that the useful criteria are changing, as in my reply to Retra. Who in 2014 is sitting here selecting a language based on whether or not it is "compiled" or "interpreted" as opposed to picking it based on libraries, or simple real speed (as opposed to worrying about where the speed comes from)? Who saw the wave of Javascript JIT interpreters and yelled "Crap, there goes Javascript, because now it's 'compiled' and that change now makes it suck"? The way we're going to be characterizing language families in 2020 will make such 1990 concerns look quaint and there's little reason not to start thinking about it now, since 2014 looks more like 2020 than 1990.

Re:Computer Language Benchmarks Game – Rust vs. Go by jmgao on Wednesday December 24, 2014 @12:14AM (#8791650)
Scala hits all of those checkmarks (and checks them off more completely than go) and is explicitly designed such that you can use it as a scripting language.
Re:Computer Language Benchmarks Game – Rust vs. Go by heydenberk on Tuesday December 23, 2014 @09:55PM (#8791345)
Go is garbage collected. I don't think that's a necessary or sufficient criteria to call something a scripting language, but it makes sense why people might consider it such.
Re:Computer Language Benchmarks Game – Rust vs. Go by laumars on Wednesday December 24, 2014 @05:51AM (#8792394)
So does C# and Java. Neither of which people would call scripting languages.

In fact if one was to group Go with other languages, those two would make sensible comparisons