Author Topic: The V Programming Language  (Read 152 times)

Offline AIR

  • BASIC Developer
  • Posts: 660
The V Programming Language
« on: March 26, 2019, 09:03:48 PM »
This isn't released yet, but it sounds promising, it will include cross platform GUI using NATIVE capability of the OS.

https://vlang.io/docs

Offline jalih

  • Advocate
  • Posts: 52
Re: The V Programming Language
« Reply #1 on: March 30, 2019, 12:51:41 AM »
Interesting...

Here is the 8th version of the sample program used in language comparison.

I got rid of the mutex guarded ids access inside the tasks and pass each task it's own slice of work. Fastest way to lock is not to lock. I also discovered a bug in 8th's current "tlshello" implementation. It currently won't play nice if used concurrently and it's access should be guarded with a lock. Bug report is filed!  ;D

Code: [Select]

needs net/http


var ids
[] var, tasks


\ Locker words. Locked variable is embedded into word, so wastes no dictionary space on captive locker variable.
"" dup
: lock-write literal lock drop ;
: unlock-write literal unlock drop ;


: STORIES_URL   "https://hacker-news.firebaseio.com/v0/topstories.json" ;
: ITEM_URL_BASE "https://hacker-news.firebaseio.com/v0/item/" ;


: get-ids
  STORIES_URL net:get if
    nip json>
    ' >s a:map ids !
  else
    "Error retrieving data." throw
  then ;


: task  \ ids-slice --
  ( nip ITEM_URL_BASE "%s%s.json" s:strfmt net:get if
      nip json>
      "title" m:@ nip
      lock-write . cr unlock-write
    else
      "Error retrieving data." throw
    then
  ) a:each drop ;


: start-tasks
  tasks @
  ( ids @ swap -1 8 a:slice+ 1 ' task t:task-n a:push  ) 0 7 loop
  drop ;


: wait-tasks
  tasks @ t:wait ;


: app:main
  get-ids
  start-tasks
  wait-tasks
  bye ;
« Last Edit: March 30, 2019, 01:17:58 AM by jalih »