HackerTrans
TopNewTrendsCommentsPastAskShowJobs

Val: A New Language Alternative to C++, Rust(thenewstack.io)

19 points·by wrayjustin·3 yıl önce·11 comments
thenewstack.io
Val: A New Language Alternative to C++, Rust

https://thenewstack.io/meet-val-a-new-language-alternative-to-c-rust/

12 comments

vacuity·3 yıl önce
This seems optimistic in terms of implementing ergonomic and performant memory safety.

> Whereas with Val, we said, let’s get rid of references, because references are the issue and so we have a far simpler model.

I'm somewhat interested but it sounds like the old V situation of overpromising.
pjmlp·3 yıl önce
Except V isn't sponosored by Adobe, nor has well known figures from C++ and Swift world designing it.
pjmlp·3 yıl önce
Listen to Sean Parent, also on why Adobe is backing Val,

https://adspthepodcast.com/2023/07/07/Episode-137.html

https://adspthepodcast.com/2023/07/14/Episode-138.html

Another person that is also part of the Val team is Dave Abrahams, one of the main authors of the Swift standard library.
AzzieElbab·3 yıl önce
How does one write an article about programming language without any example code?
nextaccountic·3 yıl önce
Well https://www.val-lang.dev/ has an example

> Enough, show me some code!

> Okay, okay. Here’s a simple program:

    subscript longer_of(_ a: inout String, _ b: inout String): String {
      if b.count() > a.count() { yield &b } else { yield &a }
    }

    fun emphasize(_ z: inout String, strength: Int = 1) {
      z.append(repeat_element("!", count: strength)))
    }

    public fun main() {
      var (x, y) = ("Hi", "World")
      emphasize(&longer_of[&x, &y])
      print("${x} ${y}") // "Hi World!"
    }
> This program declares two character strings, appends an exclamation mark to the longest, and prints them both after the mutation. No pointers or references are used (& in Val does not mean “address of”—it simply marks a mutation), and no unnecessary allocation occurs. The result of longer_of is a projection of the longer argument, so the mutation of z by emphasize occurs directly on the value of y. The value is neither copied, nor moved, and yet it is not being passed by reference to emphasize. The body of emphasize owns z in exactly the same way as it owns strength, which is passed by value: z is an independent value that can only be touched by emphasize.

> To better understand, notice that longer_of is not a function; it’s a subscript. A subscript does not return a value, it projects one, granting the caller temporary read and/or write access to it.

Now that's interesting. Subscripts seem to be the novel feature of this lang, they are described here https://tour.val-lang.dev/subscripts
saghm·3 yıl önce
> Now that's interesting. Subscripts seem to be the novel feature of this lang, they are described here https://tour.val-lang.dev/subscripted

I'm not sure if it's due to the name not really conveying what it what sounds like they're trying to describe or my lack of familiarity with other parts of the language, but this page doesn't really give me any clue to what a "subscript" actually is. They're very explicit that it's not a function, but from both the syntax and the usage exactly, it seems to look and act pretty much just like a function. Given that it's supposed to help avoid needing references in the language, I assume that the reason they're making this distinction is to convey that it doesn't use call stack semantics like a function call normally does, so...is it just an inlined function, or a hygenic macro defined with essentially the same syntax as a normal one except for the "subscript" keyword? I want to give the benefit of the doubt about their being something "novel" about this feature, but the confusing name and the documentation being quite verbose without really giving much detail makes me feel like either the authors don't grasp that they're just giving a new name to something existing or that they purposely are trying to make it less obvious.
silok·3 yıl önce
The subscript concept itself is nothing new, it is basically just a generalized element accessor, typically for collection types, arrays, dictionaries, etc.

https://docs.swift.org/swift-book/documentation/the-swift-pr...
timwaagh·3 yıl önce
Unfortunately it looks like symbol spaghetti. C and friends have one advantage: they look clean.
pjmlp·3 yıl önce
Indeed, so clean

http://unixwiz.net/techtips/reading-cdecl.html

https://en.wikipedia.org/wiki/Most_vexing_parse

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p26...
nextaccountic·3 yıl önce
it uses mostly the same sigils and syntax elements from C, like &, [], etc (the ${} is for string formatting, that in C is written %d, %lu etc - which is arguably worse)

for me the problem is that it changed the meaning of & gratuitously
frou_dh·3 yıl önce
*familiar
[deleted]·3 yıl önce