Programming

24475 readers
105 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
876
 
 

cross-posted from: https://lemmy.ml/post/24744907

I rewrote some popular games for the terminal! You can play 2048, the snake game, tic-tac-toe, connect 4, and many more.

There's still a bunch of games to be made, so feel free to contribute :)

All contributions are welcome!

877
 
 
878
879
 
 

I'm making a language with a lot of inspiration from rust and was experimenting with alternative enum syntax. It relies on literals to be types in order to convey information on the different options.

I don't really get on well with Typescript but having the ability to use literals as types is something I really liked as a lot of the times I use static string literals as errors. and having all the variants upcast through types makes it easier to do pattern matching.

Plain-text transcription of the image:

// using rust like enum syntax
Option<T> (
  | "Some" T
  | "None"
)

fn match_demo() {
  let some_option = Option "Some" "text";
  let none_option = Option "None";

  match some_option {
    "Some" "hello" => print("oh hi there"),
    "Some" text => print("Option is {text}"),
    "None" => print("Option is {text}"),
  }
}

// Or maybe more experimental syntax
Option<T> (
  | T
  | ()
)

fn match_demo2() {
  let opt = Option "something";
  match opt {
    "text" => "matching directly",
    var => "bind to variable",
    () => "nothing",
  }
}
880
 
 

Weird title, sorry. Let me try and explain.

Goal: Convert simple higher level script into a low level logic gate mess. Basically, I want to build my own custom computers in Factorio with circuit networks. I can easily create any type of logic gate that I want, similar to how computers Minecraft have been built, but with more options.

It would be super nice to code in something similar to Python but have it "compile" into clusters of logic gates. Of course, functionality would be extremely limited, but that is OK and I don't need to boil the ocean.... yet...

(TBH, this sounds really close to what I know about programming FPGAs.)

881
882
883
884
885
 
 

Neat article about avoiding a memcpy in a circular buffer.

886
 
 

cross-posted from: https://lemm.ee/post/52336135

887
 
 

I think Deno made a huge mistake.

Deno intended to be the redo of 'Javascript outside the browser', making it simpler while getting rid of the legacy.

When Deno was announced in 2020, Deno was its own thing. Deno bet hard on ESM, re-used web APIs and metas wherever possible, pushed for URL imports instead of node_modules, supported executing typescript files without tsx or tsconfig.json and so on.

However since 2022, Deno is trying to imitate Node more and more, and this is destroying Deno's ecosystem.

Users' Perspective

"If Deno implemented Node APIs and tried to imitate Node and NPM ways of doing things, existing libraries and frameworks written using Node will automatically work in Deno and thus adopting Deno will be easier." I don't know who said this, someone must have said this.

What has happened instead, is that Deno trying to imitate Node has disincentivized formation of any practical ecosystem for Deno, while the existing libraries and frameworks are unreliable when used with Deno.

I tried using Next.js via Deno some time back, and Next.js dev server crashed when Turbopack is enabled. There is a workaround, so for the time being that issue is solved. But today there is another issue, type checking (and LSP) for JSX is broken.

This is my experience with using Node libraries with Deno. Every hour of work is accompanied with another hour (sometimes more) of troubleshooting the libraries themselves.

I think this is the consequence of trying to imitate something you are not. Deno is trying to be compatible with Node. but there are gaps in the said compatibility. I think achieving compatibility with Node is hard, and the gaps in compatibility will stay for a long time.

For example, at the time of writing, FileHandle.readLines is not implemented in Deno.

import fs from 'node:fs/promises';

const hd = await fs.open(Deno.args[0]);
for await (const line of hd.readLines()) {
	console.log("Line: ", line);
}

The above script crashes despite having no issues with Typescript.

$ deno check test.ts
Check file://path/to/test.ts
$ deno run -R test.ts input.txt
error: Uncaught (in promise) TypeError: hd.readLines(...) is not a function or its return value is not async iterable
for await (const line of hd.readLines()) {
                            ^
    at file://path/to/test.ts:4:29
$

Using NPM libraries is also typically accompanied with a complete disregard for Deno's security features. You just end up running deno with -A all the time.

Library devs' Perspective

Deno 1.0 is released, and library devs are excited to join the ecosystem. Projects like drollup, denodb, drizzle-deno are started,

But then Deno announces Node and NPM compatibility and all that momentum is gone.

Now, it seems like Deno's practical ecosystem is limited to first party libraries like @std and Fresh, libraries on JSR, and a small subset of libaries on NPM that works on Deno.

If you look at the situation from library or framework dev's perspective, it all seems reasonable. Most of them are not new to Javascript; they are much more familiar with Node than with Deno.

When Deno is announced, some of them might want to contribute to Deno's ecosystem. But then Deno announces Node and NPM compatibility, and now there is not enough incentive to develop software for Deno. It doesn't matter that Node compatibility is spotty, because they'd rather just go back to using Node like they're used to. Supporting multiple runtimes is painful. If you want to understand the pain, ask anyone who tried to ship any cross platform application written in C or C++.

Deno should have promoted its own API

If the competition is trying to be more like Node, Node is the winner.

There is a lesson to be learned here. If you are trying to replace a legacy system, don't re-implement the same legacy system. Instead, put the burden of backwards-compatibility on the legacy system.

Deno aimed to uncomplicate Javascript. (Deno's homepage literally says that.) By trying to mimic Node, Deno has unintentionally put Node's complexity problem at the center of the stage. And now, it cannot be removed. Instead of being a brand new thing, Deno ended up being a less reliable variant of Node.

Deno should have supported its own API on top of Node instead. Since Deno controls its API, supporting its own API on Node would be simpler than supporting Node APIs. For library and framework developers, libraries made for Deno would work on Node and there would be no need to support multiple runtimes.

This would have resulted in a much larger ecosystem of software made for Deno which is more reliable and free of Node's legacy.

888
889
 
 

This is a bit of frustration post. I'm not a professional and some stuff is super confusing. And it might not even be programming only, as this seems to be a general issue when it comes to signing and security in computers. Every time I have to reinstall my operating system (its really only a few times in a decade), one of the things i fear most is signing into Github, signing keys and setting up local git on my Linux machine. I want the verified badge. Every time its a fight in understanding and doing the right steps, creating gpg keys and access tokens and such.

Am I the only one who struggles with this? Right now I have set it up and my test repository has the badge again. Do people care about this? Especially people like me who does a few little CLI and scripts and nothing else. Am I doing enterprise level security for the sake of an icon or is this really more secure? I do not have ANY professional background. As said I seem to have setup correctly now, so this is not asking for troubleshooting. Just wanted hear about your opinion and experience, and if any of you care.

890
891
 
 

I've been trying to figure this out for over a year now.

This is my latest concept that I'll try to make.

What do you all think?

892
 
 

yes, not a unix os but rather unix-like, and i want to program all of it on python, is that possible?? even the kernel, i want it all python. i know most kernels use c++ or c* but maybe python has a library to turn c* into python?? i'm still sort of a beginner but thanks and i would appreciate the answers

893
 
 

Hi! I've been thinking about it, why people decide to program? Why do people chose a lonely job? Why do they decide to work every day in front of a screen in an office or at home? Why passing your day solving puzzle after puzzle?

I am a very social person, and sometimes being alone, for long times, in my office makes me feel incredibly sad (I don't program as a job but I am lucky enough that I have time to study and work on open source software from there sometimes). Yes, it's good that I am not under a bright hot sun in summer and I am not always fatigued by the harshness of a physically demanding job, but at the same time being lonely so much time with something that requires so much focus have its cons as well.

I have some experience in more physical jobs and, while it was definitely more tiring, it was good to have someone to talk to, for example, and to detatch from your thoughts for a while. You can also procrastinate so much being in front of a PC and finding the skills and tweaks to not do it, especially for someone who was addicted to the internet, is another job by itself.

Deciding to study programming for me (all on my own by reading documentation) was an incredibly hard decision and today it still requires a huge amount of will and strength. I was depressed for years and the cognitive impairment coming from depression (and who knows maybe from genetics) is something I am starting to unwind only now. I believe someone is what it is, but the power of change is always there, and cannot be ignored.

I might have an etremely hard time to study and do it veeery slowly while other people can be at university and pass exam after exam, but I'm also conscious I was starting from nothing, nothing at all. From the pits of years of suicidal depression, sometimes filled with substance abuse.

I will be honest, it was and sometimes still is excruciatingly painful.

Coming out from there was the hardest thing I did in my life and it took years. I still need to work on traumas, and that probably takes most of my energies still today.

I see programming and computers not only as something to focus my (so strong) neurotic energies on, something to help me build my cognitive skills, or a possibly well payed job which I could do from everywhere, but also as something to work on and to improve life for other people.

If you read books like digital minimalism by cal Newport, stolen focus by Johan hari, or program or be programmed by Douglas rushkoff you can understand why software needs to be better and to be for people. I lived it by myself: internet, smartphone and mainstream software is becoming more and more hooking, less and less of an instrument and more and more of a tool to control people. I was addicted for years: a fragile person laying towards the shadow of a world that seemed to fully accept me, while it was using and taking out of me every drop of the little hope and energy i had instead.

I could work as a frontend webdev, I have all the skills I need to host WordPress or static websites on a VPS. I have some JavaScript base knowledge, I can use SCSS and HTML. And that would probably give me some very good extra income. I was even asked to work as a webdev but that never went on, I simply feel like I didn't care enough and it kinda faded. (Probably most of people would think I am incredibly stupid, and probably I am).

So I asked myself: why do you program? What is the purpose? Why do I prefer to keep my very low income job instead of trying making some decent money with webdev? Why I decided to start learning Rust from zero again instead of focusing on something highly demanded like JavaScript? Why do I prefer to work for free on a free Hugo theme that can build thousands of websites (that would be payed decently) instead of selling the websites themselves?

I think I finally understand it now, it is because I suffered, and I suffered a lot.

I cannot bear someone else in the world suffering that kind of pain. And if I will be able to build, one day, software that helps someone else to come out of this dystopian matrix which is the current software landscape, to which i was so so ipnotized, I will be the happiest person in the world.

I will never be as skilled as an engineer, I will never understand the complicated maths behind coputer machines, I will also probably keep being very poor, and I will probably never change the world. But I feel like software right now lacks humanity, lacks emotion, and since I feel I have so much of both and some skills on it, it is my duty to at least try to do something as difficult as trying to put both of them into my development. There are probably countless super skilled engineers working for big techs, but how many of them put their full hearth into what they are doing?

This is why I program, and it can be ad painful as fulfilling at the same time, other than extremely hard in a not very rewarding approach.

Why you do it?

894
895
 
 

I added this language to my watch list some time ago and forgot about it, until I got a notification about a new release (0.15) yesterday.

I'm someone who is familiar with system languages (C, Rust) and shell languages (Bash, Zsh, ..). But don't have much experience, at a proficient level, with any languages setting in between.

So I gave Koto's language guide a read, and found it to be very well-written, and the premise of the language in general to be interesting. I only got annoyed near the end when I got to @base, because I'm an anti-OOP diehard 😉

I hope this one well start to enjoy some adoption.

896
 
 

Saw this on: https://donotsta.re/notice/ApmsQzRYt4SeNH543k

So wanted to share.

897
898
899
 
 

They slowly started locking down the platform for people without accounts and it has been really annoying to use the website since. First it was not possible to search for code, then even searching for issues got more and more difficult with it randomly failing, and now it's gotten to the point where I can't search for a fucking project anymore!

Github's search is becoming as bad as reddit's, where if you want to find anything, a secondary service like SourceGraph, GrepApp, or even a dumb search engine is better. Sometimes those haven't indexed what I need (especially code search), so I have to download the bloody tarball and rg for whatever the fuck it is I was looking for. Sometimes it will also block the VPN I'm using, so I have to proxy to a non-VPNed machine. The world could do without these unnecessary roadblocks.

What also grinds my gears is requiring an account to contribute. There is no way to send in a patch, raise an issue, or anything without an account there, so by if a project being on github, you have no choice but to give Microsoft your data to participate in opensource. Don't get me wrong, mailing-lists are filth, but and I'd rather claw my eyes out than participate in any project demanding their use, but Microsoft being the "lesser evil" is not a good look.

Please, for the love of opensource, get your project off of github, please. It's a monopoly at this point and doing microsoft things. This isn't the end and they'll probably do more stuff to see how far they can push it. We'll all be the boiled frogs.

Yes, I know they have a CI and some other features, but if all you're doing is hosting your code, please consider an alternative.

Possible alternatives in alphabetic order:

  • Codeberg (could have federation in the future)
  • Gitlab (has CI)
  • ~~OneDev (no git SSH clone but feature-rich)~~ not an instance for the public
  • Radicle (no CI, but federated)
  • Sourcehut (minimalist, but fast as fuck)

or maybe others will suggest more.

900
view more: ‹ prev next ›