13 ms·
Vale's first prototype for immutable region borrowing
- halfmatthalfcat 3y agoFrontend in Scala - very cool!
- cantaloupe 3y agoCongrats to Evan on the milestone! I enjoy reading the Vale articles even though I have no programming language design or compilers experience.
- davidkunz 3y agoMe too, the articles are great and I'm excited about the future of Vale.
- pjmlp 3y agoSame here, I just wished there was another name for it. Now we have Evan with Vale, and Adobe’s Software Technology Lab wit Val, it will be great searching for related stuff. https://www.val-lang.dev https://www.val-lang.dev
- hobo_mark 3y agoThere's also been a language called Vala, active since 2006! https://vala.dev https://vala.dev
- pjmlp 3y agoYeah, that one as well.
- solarkraft 3y agoAnd there's the game company actively developing low-level open source software Valve, which my mind first sprung to.
- promiseofbeans 3y agoNot to forget https://www.val.town https://www.val.town, which call their lambda functions 'vals'
- iddan 3y agoWhen I entered the article I thought it was talking about Vala
- verdagon 3y agoYep, this was my bad. I thought Vala was dead because of a certain post (I think it was this one [0]), and because I rarely ever heard anyone mention it. I suspect I was wrong. I've been tossing around the idea of switching Vale's name to Valence to help avoid confusion. [0] https://www.phoronix.com/news/GNOME-Vala-Bassi https://www.phoronix.com/news/GNOME-Vala-Bassi
- NeutralForest 3y agoSame, I don't have the background to understand the articles in most cases but it's interesting nonetheless.
- verdagon 3y agoThanks! Glad you enjoy them =)
- cpeterso 3y ago“Vale is Fast: Vale is AOT compiled to LLVM, statically-typed, and uses the new generational references technique for memory safety with speed and flexibility, and will soon have region borrow checking to make it even faster.” https://vale.dev/ https://vale.dev/
- jupp0r 3y agoThe approach of having options to optimize hot code paths with zero cost abstractions while still not having to worry about memory management in the vast majority of the rest of your code sounds like the best of both worlds to me (given that we only trade performance, not safety for convenience).
- mgaunard 3y agoI write C++ exclusively and never worry about memory management. I don't use smart pointers since shared ownership is a bad concept. The problem of memory management is largely trivial.
- willvarfar 3y agoThe problem of memory management is largely trivial _if_ you are in a small clean opinionated private codebase without cruft, collaborators, third party code, ...? :) Google et al have been working on sanitisers etc because, even in well kept codebases with strict coding standards that are rigorously applied in reviews, memory bugs do actually creep in.
- zelphirkalt 3y agoNot disagreeing with your first paragraph and will add, that memory management mistakes happen to the best. But it is also probably true, that Google and others do this, because they know there will always be someone committing shit, no matter, whether they are at Google or another big company. So they want guarantees, not blind trust.
- mgaunard 3y agoThird party code is a risk and should always be carefully managed and properly isolated. This applies regardless of programming language. Of course the web people and their "frameworks" is just another demonstration of how bad relying on third party code is.
- chubot 3y ago
- hu3 3y ago...more predictable latency than tracing garbage collection. ...better performance and cache friendliness than reference counting. ...prototype and iterate more easily than with borrow checking. Ok, you had my curiosity, but now you have my attention. Just started following your RSS feed: https://verdagon.dev/rss.xml https://verdagon.dev/rss.xml
- iopq 3y agoFinally some new ideas for AOT compiled languages that don't devolve to "what if we just have memory bugs some of the time?"
- reilly3000 3y agoI have a new favorite HN comment :)
- JonChesterfield 3y agoGenerational references leak if a counter reaches int_max and involve an increment on alloc and on free. Seems pretty close to reference counting to me. https://verdagon.dev/blog/generational-references https://verdagon.dev/blog/generational-references Statically eliminating memory operations does seem to be a win though.
- foota 3y agoMy understanding is that this has some benefits over reference counting, though it it similar. Part of the issues with reference counting is that they are shared, meaning that it needs to be atomically incremented and decremented whenever you make a new reference (for instance in C++ if you return a shared_ptr or similar). Generational references though instead track something as a part of the value you pass around, meaning that it has better locality and doesn't suffer from contention. Copying references is assumed to be more frequent than allocating and freeing, so this is a win.
- flohofwoe 3y agoTypically that slot is disabled on overflow, so that no more objects can be created at that slot / memory location, which avoids the handle collision. The slot could be recycled at specific points in the code when it is certain that no more handles for this slot are out in the wild (not sure if Vale does that) (Or possibly the whole region could be discarded once it was running full, and the physical memory recycled at a new virtial address. There's plenty of virtual address space to burn through when not limited to 32 bits)
- bluejekyll 3y ago> Vale-specific pre-optimizer, similar to Rust's Cranelift I think this might instead be MIR, mid-level IR, there’s a good blog post here: https://blog.rust-lang.org/2016/04/19/MIR.html https://blog.rust-lang.org/2016/04/19/MIR.html Cranelift is a compiler backend, mainly focused on JIT, but theoretically could replace LLVM, there’s an alternative backend being worked on but has limitations: https://github.com/bjorn3/rustc_codegen_cranelift https://github.com/bjorn3/rustc_codegen_cranelift
- 3cats-in-a-coat 3y agoCorrect me if I’m wrong, but I believe this is an alternative way to describe a system that is equivalent to copy on write, but with ahead of time analysis on reference counting, which means we can eliminate most of reference counting. We have this kind of analysis is already done in reference counted languages like Swift which also do copy on write.
- GolDDranks 3y agoThis is not a reference counted system, but you manually free the memory. However, the references are safe to use in the sense that they can detect when the object they are referring to, is deleted.
- flohofwoe 3y agoIt's not ARC, and not reference counting at all, but closer to an idea that has become quite popular in game development (because it's trivial to implement, doesn't need compiler support, and works in any language that has indexable arrays): https://floooh.github.io/2018/06/17/handles-vs-pointers.html https://floooh.github.io/2018/06/17/handles-vs-pointers.html (disclaimer: I only wrote a blog post about it, that idea is much older and probably has been re-invented many times over since the first computers were built) Essentially "non-owning weak references with spatial and temporal memory safety". What is similar to ARC though is that moving that stuff into the language lets the compiler remove redundant handle-to-pointer conversions, similar to how with ARC the compiler can remove redundant refcounting operations.
- sirwhinesalot 3y agoThey don't seem to be quite zero cost though when applied to the whole program, because they require changes to the allocator to ensure the generations are never overwritten by user data. If you store them inline with the program data for max speed(tm) you need to ensure that e.g. after 2 2kb chunks are deleted, you don't overwrite them with a 4kb chunk, because that would trample over a generation. If you do keep the generations inline and rely on a statistical approach, you have to be very careful to never generate "common numbers" like 0 as a generation because then it's extremely likely there will be a collision. It'd a hard problem and I'm quite curious how all the edge cases are handled.
- lovich 3y agoThe callout to the Easter egg was a nice social hack to see how many people read the article in detail
- verdagon 3y agoFunny story, that wasn't my original intent! I have a programming blog, but every day I'm finding weird facts that I want to write about, so I tend to sneak them in: * I like mythical birds, so I wrote an article about memory safety and mythical birds: https://verdagon.dev/blog/myth-zero-overhead-memory-safety https://verdagon.dev/blog/myth-zero-overhead-memory-safety * The Rosetta stone fascinates me, so I wrote an article on linear types and the Rosetta stone: https://verdagon.dev/blog/linear-types-borrowing https://verdagon.dev/blog/linear-types-borrowing * I heard about a pigeon named G. I. Joe so I added a side note to about it on the C++ article at https://web.archive.org/web/20230629052606/https://verdagon.dev/blog/vale-memory-safe-cpp#borrowless-affine-style https://web.archive.org/web/20230629052606/https://verdagon.... * And now I had to find a way to spread the word of Brigadier Sir Nils Olav III, so I used a side note in this one. It's embarrassing but I was giggling with glee all day yesterday at the thought of putting that note in! I suspect this is a curse that a lot of bloggers can empathize with, but they don't have the proper lack of professionalism that I do. Once I had these little side notes, I figured I'd give some sort of prize to the first person who told me they saw them, which evolved into "comment somewhere mentioning it!" which I guess is a social hack? Maybe? I'll allow it!
- garganzol 3y agoA distinguishing feature of Vale is: a) natively-compiled safe language b) that still has a sane syntax. I remember seeing Vale many years ago (~10). Back then, it was something revolving around Gnome project, but now it still has a pre-prelease version 0.2-alpha. This means that the project's progress is relatively slow, but the language is very interesting to me. Update: I confused Vale with Vala! Vale is the new project, Vala is 10+ years old, but they have an intersection of syntax, goals and ideas. That's why I was misled by seeing a similar name. Val-vale is almost the same!
- asabil 3y agoI think you are confusing Vale with Vala[1] :) [1]: https://vala.dev/ https://vala.dev/
- modernerd 3y agoVale needs more sponsors! https://github.com/sponsors/ValeLang https://github.com/sponsors/ValeLang Let's use this post's time on the front page to help the project meet its $3,000/month goal. I'd love to help Evan work on this full time (I'm a sponsor). A fast and safe language that's also fun to prototype with is worth supporting.
- cinntaile 3y agoWhat's the difference in revenue split github vs patreon when sponsoring?
- Bedon292 3y agoGitHub: They keep 6%. With 3% for CC fees and 3% for GitHub. [1] Patreon: Varies a bit more. Patreon takes 8%, unless they have been on the platform since before the 2019 change and are still on the 5% plan. And payment processing depends on size. Under $3 is 5% and $0.10 per transaction. Over is 2.9% and $0.30 per transaction. And more if PayPal or Venmo in not USD. [2] So the split seems much better on GitHub. But the conditions are a bit different for using the platforms, and you can get perks on Patreon which you may not be able to get on GitHub. I can't remember who / which project but I believe I saw one that said something about a difference in taxes / VAT and not being able to give some of the perks on GitHub because of it. Cannot find it right now though. [1] https://docs.github.com/en/sponsors/sponsoring-open-source-contributors/sponsoring-an-open-source-contributor https://docs.github.com/en/sponsors/sponsoring-open-source-c... [2] https://support.patreon.com/hc/en-us/articles/11111747095181-Creator-fees https://support.patreon.com/hc/en-us/articles/11111747095181...
- verdagon 3y agoThanks for your support, I really appreciate it =) I would love to do this full time!
- cbsmith 3y agoJust acknowledging the Nils Olav Easter Egg.
- megamorf 3y agoI was confused by the title because when my bubble talks about Vale they mean this: https://github.com/errata-ai/vale https://github.com/errata-ai/vale
- zahllos 3y agoThere is also https://project-everest.github.io/vale/ https://project-everest.github.io/vale/, which is a programming language used in formal verification. I was slightly confused when I first read the title as well :)
- leksak 3y agoNice "first"-type of Easter Egg! Would love to be a penguin. Keeping it would make for a good TFA though!
- verdagon 3y agoI would keep it! But alas, I have to remove it at some point today. I plan on keeping a record of all of them at https://verdagon.dev/blog/easter-egg-notes https://verdagon.dev/blog/easter-egg-notes though.
- cultureulterior 3y agoThat algorithm would be infinitely much faster if you were to use bitboards
- revskill 3y agoThanks. At least i don't have to write Rust.
- deleted 3y ago[deleted]
- JonChesterfield 3y agoNot the same language as V. The latter got a very critical review at https://mawfig.github.io/2022/06/18/v-lang-in-2022.html https://mawfig.github.io/2022/06/18/v-lang-in-2022.html which I've misattributed to Vale because they're similarly named. Leaving this here in case someone else has made the same mistake.
- amedvednikov 3y agoThis "very critical review" is just a list of small bugs that were fixed a year ago. Nothing in this article is relevant, but it still stays up, the only article in the blog.
- sealeck 3y agoNote: the author of this comment is author of "V lang".
- Tozen 3y agoThis "critical review", appears more like continuous old spam often used by detractors or to troll. It has no perceived value other than that, because it's a "review" (hit piece) of an alpha version of the language. It's 2023, and V is also in beta (0.4). Furthermore: 1) The creator of it used a disposable GitHub account, launched the review/attack for the drama, then disappeared. 2) The only thing they ever published on their blog, was the hit job on V. No other reviews ever made. 3) Anything, which had any kind of substance, is already fixed[1]. 4) A search of mawfig.github, shows how it is spammed on HN, and usually used for smearing. [1]: https://github.com/vlang/v/issues/14803 https://github.com/vlang/v/issues/14803 [1]: https://github.com/vlang/v/issues/14787 https://github.com/vlang/v/issues/14787 [1]: https://github.com/vlang/v/issues/14786 https://github.com/vlang/v/issues/14786
- conaclos 3y agoI keep wondering what "safe" means in the context of generational references. If I understand clearly, this prevents use-after-free and double-free? Thus, the program can still fail on a memory access when the expected and actual generations don't match? In this regard, this seems less "safe" than reference counting, tracing garbage collector, or borrow checking?
- kreco 3y agoIs it less "safe" than your own restricted definition then... maybe?
- flohofwoe 3y agoIt's safe the same way a segfault is safe instead of just allowing to read or write random memory through a dangling pointer, but generational indices should also allow to check at runtime if an access would be valid before actually attempting the access. Not sure if that's possible in Vale though.
- marhee 3y agoYes, I am wondering too. How would it even stop use-after-free and double-free? The "check" function accesses the allocation because it needs the generation number of the allocation. So basically, the reference needs to access the allocation to check if it can access the allocation. Right. (That doesn't work of course, because if the allocation was freed, access to the allocation and so its generation number is undefined). This seems obvious so maybe I am missing something big here? Or something entirely different is meant or targeted here with "memory safety".
- jsnell 3y agoI think the part where your reasoning is invalid is this part: > so its generation number is undefined With e.g. a random C compiler and a random malloc, that's true. But why couldn't the language and runtime cooperate to ensure it is defined? For example deallocation can write a predictable value to that slot, which is never used as a legit generation index. The memory allocator can make sure that a memory address that ever contained a generation can never contain anything else than generation ids for the entire runtime of the program (e.g. by ensuring that for a given page, all objects are the same size and the allocations are aligned to that size). The language can make sure that nothing else can get written to such a memory address by enforcing bounds checks.
- garganzol 3y agoI downloaded and tried to try Vale. The very first impression of running 'valec' compiler is that it "panics" when no arguments are given. It literally writes so: "(panic)". I want to point out that "panic" is a very strong word and should be avoided in scenarios where a normal error handling takes place. Any kind of panic is always a sign of an uncontrolled situation, and if a program ever "panics" it leaves a bad taste in the mouth. The next struggle was to get the basic help for the command-line parameters. But it's currently non-existent. The next and final stuggle: trying a hello world sample. I copied the code from the website: import stdlib.*; exported func main() { println("Hello world!"); } and saved it to 'hello.vl' file. Then, I tried to build it: > valec hello.vl However, no luck for me this time: Unknown subcommand, specify `build`, `run`, etc. Use `help` for more. It looks like I should specify 'build' command. Let's try: > valec build hello.vl Well, here is the result: Unrecognized input: hello.vl (panic) Hm. Let's try to get some help: > valec help The result of the help command is: <nothing> Not very helpful. At this point, I gave up. How does this thing work?
- emblaegh 3y agoThe github readme shows how to use the compiler. https://github.com/ValeLang/Vale#building-a-vale-program https://github.com/ValeLang/Vale#building-a-vale-program
- insanitybit 3y agoIsn't vale basically still in the R&D phase? That's how it has felt, certainly. I would expect specific commits on specific branches to work and that's it - no that they have a compiler that arbitrary people can use to start building things. Then again, their README doesn't really indiciate this and does say "Try Vale" so idk. But it seems very R&D/POC at this point.
- aktuel 3y agoFrom the home page: "Vale is currently in alpha!" (https://vale.dev/ https://vale.dev/)
- ivoras 3y agoDoes the generational reference approach do something similar to MVCC in databases (e.g. PostgreSQL)?
- a1o 3y agoI thought this was about Vala and only on a second read caught it was a different language.
- MilStdJunkie 3y agoI wish there was some way for me to know right off the bat that this article wasn't about the Vale natural language linter. I mean, it didn't take long, but still. Is there some notation for the linter nomenclature I'm missing?
- deleted 3y ago[deleted]
- jadbox 3y agoWhat is Vale used for today?
- verdagon 3y agoNot much! It's still very young, still in the prototype phases. When it's more mature and polished I hope it will be useful for those writing servers and games mostly.
- drwiggly 3y agoThis language is interesting. General usability might be a bit away? Higher RAII is something that would be nice in C++ too.
- dang 3y agoRelated. Others? Making C++ safe without borrow checking, reference counting, or tracing GC - https://news.ycombinator.com/item?id=36448759 https://news.ycombinator.com/item?id=36448759 - June 2023 (214 comments) Memory safety without borrow checking, reference counting, or garbage collection - https://news.ycombinator.com/item?id=36351415 https://news.ycombinator.com/item?id=36351415 - June 2023 (93 comments) What Vale taught me about linear types, borrowing, and memory safety - https://news.ycombinator.com/item?id=36156790 https://news.ycombinator.com/item?id=36156790 - June 2023 (12 comments) How Memory safety approaches speed up and slow down development velocity - https://news.ycombinator.com/item?id=34410187 https://news.ycombinator.com/item?id=34410187 - Jan 2023 (137 comments) The Vale Programming Language - https://news.ycombinator.com/item?id=31786487 https://news.ycombinator.com/item?id=31786487 - June 2022 (90 comments) The Vale Programming Language - https://news.ycombinator.com/item?id=25160202 https://news.ycombinator.com/item?id=25160202 - Nov 2020 (171 comments) The Next Steps for Single Ownership and RAII - https://news.ycombinator.com/item?id=23865674 https://news.ycombinator.com/item?id=23865674 - July 2020 (38 comments)
- crunchengine 3y ago[flagged]
- pxeger1 3y agoI'm 99% sure you're confusing this with V. This is Vale, which is not the same. (And V is controversial but I wouldn't say it's a scam either)
- hinkley 3y agoI feel like I'm eavesdropping on an argument that two people have been having for five years. Anyone have an explanation of what is going on here? I'm finding the article impenetrable.
- verdagon 3y agoYeah, this article was rather sparse on background, more intended for friends and sponsors and people who have been following along with Vale. A strategy that backfires with general audiences like HN! TL;DR: Vale is like a cleaner C++, and it uses generational references [0] which are similar in spirit to running with ASan [1] turned on. Generational references have a bit of overhead, but it can be removed by regions [2] or more specifically, immutable region borrowing [3]. This helps Vale achieve its goal of being a high-performance language while still remaining memory safe. Hope that helps, happy to answer any other questions =) [0] https://verdagon.dev/blog/generational-references https://verdagon.dev/blog/generational-references [1] https://github.com/google/sanitizers/wiki/AddressSanitizer https://github.com/google/sanitizers/wiki/AddressSanitizer [3] https://verdagon.dev/blog/zero-cost-borrowing-regions-overview https://verdagon.dev/blog/zero-cost-borrowing-regions-overvi... [4] https://verdagon.dev/blog/zero-cost-borrowing-regions-part-1-immutable-borrowing https://verdagon.dev/blog/zero-cost-borrowing-regions-part-1...
- burky 3y agoBeing a C# developer, I absolutely love the syntax. I also like the Universal Function Call Syntax for it's fluency, kind of like pipes in elixir or F#. I'm still going through the guide but one thing I find curious is the module naming when building your application. It seems like you clone a library to disk and then "import" it as a command line argument with the name you choose. I'm trying to wrap my head around how dependencies would work if you have the following situation: - parse library - http library (requires parse) -> import parse=~/parse/src - my_app (requires parse and http) -> import http=~/http/src parse_with_different_name=~/parse/src Note how my_app uses a different name for the parse library than http. If the http library uses "parse" in the source code when referencing the module (import parse) and my application uses "parse_with_different_name" when referencing the module (import parse_with_different_name), does that mean to compile my app I would have the following... valec build mymodule=~/my_app.vale parse=~/parse/src http=~/http/src parse_with_different_name=~/parse/src Maybe I'm missing something and maybe it's too early to worry about things like this. Regardless I am loving this language and very excited about it. Edit: trying to fix my example list