Recent

Author Topic: How come only one person alone build a new cross-compiling programming language?  (Read 1915 times)

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Most of us know the long history of Pascal, C and C++.

Is it possible for one person alone build a new programming language with cross compilation for Windows, Linux and MacOS and cross-platform GUI library?
No IDE so far, only plugins for some editors.

Can the result be really useful for a professional environment?

V (programming language)
https://vlang.io/
https://github.com/vlang/v
« Last Edit: July 20, 2019, 07:58:08 pm by valdir.marcos »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
It's a basic transpiler. Same as pas2js which is made by Mattias, so not really unique. Not even within the ontopic content of this forum. (which this thread is not)




LemonParty

  • Jr. Member
  • **
  • Posts: 58
Make a kiddie language can take about several months, but write >1M lines of a complex code for a serious solution...

You have to be a person about whom Adolf was dreaming about.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
I find built in C/C++ translator interesting (https://vlang.io/docs#cpp):
Code: C  [Select][+][-]
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. int main() {
  6.         std::vector<std::string> s;
  7.         s.push_back("V is ");
  8.         s.push_back("awesome");
  9.         std::cout << s.size() << std::endl;
  10.         return 0;
  11. }

Run v translate test.cpp and V will generate test.v:
Code: C  [Select][+][-]
  1. fn main {
  2.         mut s := []
  3.         s << 'V is '
  4.         s << 'awesome'
  5.         println(s.len)
  6. }

Although this example is trivial, it is said that whole Doom can be translated to V this way.

Also V does not need detailed wrappers for C libraries. If I read it well wrapper was needed only for sqlite3_column_int (https://vlang.io/docs#calling_c):
Code: C  [Select][+][-]
  1. #flag -lsqlite3
  2.  
  3. #include "sqlite3.h"
  4.  
  5. struct C.sqlite3
  6. struct C.sqlite3_stmt
  7.  
  8. fn C.sqlite3_column_int(C.sqlite_stmt, int) int
  9.  
  10. fn main() {
  11.         path := 'sqlite3_users.db'
  12.         db := &C.sqlite3{}
  13.         C.sqlite3_open(path.cstr(), &db)
  14.  
  15.         query := 'select count(*) from users'
  16.         stmt := &C.sqlite3_stmt{}
  17.         C.sqlite3_prepare_v2(db, query.cstr(), - 1, &stmt, 0)
  18.         C.sqlite3_step(stmt)
  19.         nr_users := C.sqlite3_column_int(res, 0)
  20.         C.sqlite3_finalize(res)
  21.         println(nr_users)
  22. }
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
I find built in C/C++ translator interesting (https://vlang.io/docs#cpp):

IMHO it is telling that V is more C++ shorthand than a real language.

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Anders Hjelsberg did that for - the ancestor of - Turbo Pascal:
At least CP/M and MSDOS
https://en.wikipedia.org/wiki/Anders_Hejlsberg
« Last Edit: July 22, 2019, 02:02:22 pm by Thaddy »
Specialize a type, not a var.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
I find built in C/C++ translator interesting (https://vlang.io/docs#cpp):
IMHO it is telling that V is more C++ shorthand than a real language.

I rather believe author's goal for that part of V was more to embrace C/C++ libraries and make their use very easy for developers.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
I find built in C/C++ translator interesting (https://vlang.io/docs#cpp):
IMHO it is telling that V is more C++ shorthand than a real language.

I rather believe author's goal for that part of V was more to embrace C/C++ libraries and make their use very easy for developers.

So why do you need to convert C++ to V then? Or is it for headers only?

Anyway, what you say is an intention, what I say is an opinion on the result. Both can be true, IOW he wanted to align for interoperability, and noticed he had to effectively structure his language as C++ to achieve this. He would not be the first.

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
I rather believe author's goal for that part of V was more to embrace C/C++ libraries and make their use very easy for developers.
Quote
Anyway, what you say is an intention, what I say is an opinion on the result. Both can be true, IOW he wanted to align for interoperability, and noticed he had to effectively structure his language as C++ to achieve this. He would not be the first.
The intention of V is to create a basic subset that satisfies most needs. It is an effort to drop all crap that went into c++ and it does a similar job to clang, even better. It is a filter as you correctly observed.

E.g.: We can do this too:
Code: Pascal  [Select][+][-]
  1. program untitled;
  2. {$macro on}{$define with:=throwerroronwith}
  3. procedure throwerroronwith;
  4. begin
  5.   {$error do not use with}
  6. end;
  7.  
  8. begin
  9.  with Tobject.Create do;
  10. end.

This will prevent a programmer from using with.... 8-)
« Last Edit: July 23, 2019, 02:15:01 pm by Thaddy »
Specialize a type, not a var.

mas steindorff

  • Hero Member
  • *****
  • Posts: 532
...
E.g.: We can do this too:
Code: Pascal  [Select][+][-]
  1. program untitled;
  2. {$macro on}{$define with:=throwerroronwith}
  3. procedure throwerroronwith;
  4. begin
  5.   {$error do not use with}
  6. end;
  7.  
  8. begin
  9.  with Tobject.Create do;
  10. end.

This will prevent a programmer from using with.... 8-)
Cool, where did you learn this from?
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Cool, where did you learn this from?
As this bug report by Thaddy shows, his example did not really work anyway. ;)

 

TinyPortal © 2005-2018