zongor

joined 4 years ago
 

CW: Brezhnev

[–] zongor@hexbear.net 2 points 6 months ago* (last edited 6 months ago)

Luau seems to be a typescript/rust mixture with a pinch of Fortran. It’s serviceable but it’s limited in its primitive types. That’s a different issue I’m still thinking of but that’s not for this one.

[–] zongor@hexbear.net 3 points 6 months ago* (last edited 6 months ago) (8 children)

Right now I’m only focused on look and taste. For reference the closest to what the end product is it’s going to be a typed lua, really simple and easy to understand. I looked at ML, Haskell but they seemed a bit too esoteric for a new dev. Pascal I totally forgot about, should look at that. I also like rusts syntax but I’m not sure if the way the implementation syntax is obvious.

Edit: looked at pascal and this looks similar to an early draft of mine lol. I think I moved away from the style of syntax (I used ‘as’ instead of ‘of’) was that it made the declaration really long and the type being at the end of it means you would need to wait to allocate memory until the whole line is parsed in.

17
submitted 6 months ago* (last edited 6 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 

Hello all, i'm trying to figure out a language syntax and I keep going in circles, maybe some opinions from other devs may help.

For a given programming language what is the most efficient & cleanest way of describing a variable, type, etc?

Here is a list of ones I have considered. (psudocode)

C style (structs and return type prefix), pros: simple, really succinct, cons: annoying lexing because return type is ambiguous.

struct Vec3 {
  f32 v[3];
}
struct Player {
  char *username;
  Vec3 pos;
  Color appearance;
}
Player[] login(Player p, char *password) {
...
}
Player me("me", Vec3(0.0,0.0,0.0), Color(255, 0, 0));
login(me, password);

Rust style (function prefix, arrow return type), pros: separation of data and implementation makes composition easier. Cons: not very intuitive for learners.

struct Player {
  username: str,
  pos: Vec3,
  appearance: Color,
}
impl Player {
  fn login(self, pass: str) -> Vec<Player> {
  ...
  }
}
let me: Player = Player {username="me", ...
me.login(password);

Typescript style (similar to rust but without arrows, also OOP). pros: simple, easy to understand. cons: OOP can cause problems

class Player {
  username: string;
  pos: Vec3;
  appearance: Color;
  constructor(username: string, pos: Vec3, appearance: Color) {
    this.username = username;
    ...
  }
  login(password: string):Player[] {
  ...
  }
}
let me: Player = Player(...
me.login(password);

Fortran style (types below definition). Pros: clear whats going on? (maybe too used to fortran weirdness). Cons: extremely verbose.

type player
  string :: username
  real(kind=32), dimension(3) :: pos
  integer(kind=8), dimension(3) :: appearance
contains
  procedure :: login
end type player

player function init_player(username, position, appearance) result(this)
      string :: username
      real(kind=32), dimension(3) :: position
      integer(kind=8), dimension(3) :: appearance

      this%username = username
      this%position = position
      this%appearance = appearance
end function

function login(this, password) result(players)
  class(player) :: this
  string :: password
  player, dimension(:), allocateable :: players
  ...
end function
...
player :: me
me = Player("me" ...
me%login(password)

Go style, types after like rust/typescript but no :, interfaces instead of OOP, prefix types on the left of functions. Slices also backwards. Pros: simple, cons: syntax is backwards and weird, implementing a tupe would be annoying.

type Player {
  username string
  position Vec3
  appearance Color
}
func (p Player) login(password string) []Player {
...
}
me := Player("me" ...
me.login(...

Let me know what you think, thanks all!

 

Prefix this with: not that this matters at all. There have been a number of recent instances of democrats moving to the Republican Party. From a procedural POV is there anything stopping a democrat from switching to the Green Party, PSL, or the like?

[–] zongor@hexbear.net 2 points 6 months ago

I won’t be happy until I can mount my thermostat over 9p

 

Idk how many of you had to/have to write highly concurrent code in languages but I saw "Race Condition" today and panic'd

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net @PaX@hexbear.net

 

Spent day 16 trying to get elixir working with emacs. Hope you all are doing well with the current problem.

17 looks fun, its building a 3 bit VM. Maybe Ill start skipping around instead of going in order.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net @PaX@hexbear.net

7
Advent of Code 2024 Day 15 (adventofcode.com)
submitted 6 months ago* (last edited 6 months ago) by zongor@hexbear.net to c/programming@hexbear.net
 

Hey all sorry I haven't posted in a bit, lifes gotten a bit hectic but im back to posting, hopefully daily. Heres a thread for the last few days, haven't been able to look at them at all but might switch from Elixir to something I know like Go just to make it a bit easier.

@Enjoyer_of_Games@hexbear.net @Speaker@hexbear.net @gay_king_prince_charles@hexbear.net @iByteABit@hexbear.net @PaX@hexbear.net

[–] zongor@hexbear.net 2 points 6 months ago

Thanks comrade, yeah can do. Haven't had the time to do it daily since life got unexpectedly busy but planning on doing more. Ive been able to finish day 1 and then havent had time to do any others lol. lambda prolog really interesting, very advanced stuff. I vaguely remember a esolang years ago that lambda calculus but I can't remember anymore.

[–] zongor@hexbear.net 13 points 7 months ago (1 children)

What a strapping young lad

[–] zongor@hexbear.net 3 points 7 months ago

I’m in the same boat; I’ve had time to do day 1 and that’s it

[–] zongor@hexbear.net 6 points 7 months ago

I also am burger brained and thought this

[–] zongor@hexbear.net 2 points 7 months ago
[–] zongor@hexbear.net 1 points 7 months ago

Prefix with I don't know much about Kotlin except that its a JVM language. It looks like you are programming in a functional style more than a OOP or imperative style. So in an imperative style you would have more intermediate values, but in a function style you are trying to reduce unnecessary intermediate values and have the output of one function pipe into the next function in the chain.

[–] zongor@hexbear.net 3 points 7 months ago
[–] zongor@hexbear.net 3 points 7 months ago
view more: ‹ prev next ›