Programming

26050 readers
72 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
26
 
 

In the previous post, JADEx introduced a new feature ~~Immutability~~.
Through community feedback, several confusions and limitations were identified.

In v0.42, we have addressed these issues and improved the feature. This post explains the key improvements and new additions in this release.


Improvements

~~apply immutability~~ -> apply readonly

  • The previous term (Immutability) caused misunderstandings.
  • Community feedback revealed that “Immutable” was interpreted differently by different developers, either as Deeply Immutable or Shallowly Immutable.
  • In v0.42, we replaced it with readonly.
  • Meaning: clearly indicates final by default, preventing reassignment of variables.

Expanded Scope of final keyword: now includes method parameters

  • v0.41: final was applied only to fields + local variables
  • v0.42: final is applied to fields + local variables + method parameters
  • Method parameters are now readonly by default, preventing accidental reassignment inside methods.

Example Code

JADEx Source Code

package jadex.example;

apply readonly;

public class Readonly {

    private int capacity = 2; // readonly
    private String? msg = "readonly"; // readonly

    private int uninitializedCapacity; // error (uninitialized readonly)
    private String uninitializedMsg;    // error (uninitialized readonly)

    private mutable String? mutableMsg = "mutable";  // mutable

    public static void printMessages(String? mutableParam, String? readonlyParam) {

        mutableParam = "try to change"; // error
        readonlyParam = "try to change"; // error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(String[] args) {
        var readonly = new Readonly();
        String? mutableMsg = "changed mutable";

        readonly.capacity = 10; // error
        readonly.msg = "new readonly"; // error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

Generated Java Code

package jadex.example;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import jadex.runtime.SafeAccess;

//apply readonly;

@NullMarked
public class Readonly {

    private final int capacity = 2; // readonly
    private final @Nullable String msg = "readonly"; // readonly

    private final int uninitializedCapacity; // error (uninitilaized readonly)
    private final String uninitializedMsg; // error (uninitilaized readonly)

    private @Nullable String mutableMsg = "mutable";  // mutable

    public static void printMessages(final @Nullable String mutableParam, final @Nullable String readonlyParam) {

        mutableParam = "try to change"; //error
        readonlyParam = "try to change"; //error

        System.out.println("mutableParam: " + mutableParam);
        System.out.println("readonlyParam: " + readonlyParam);
    }

    public static void main(final String[] args) {
        final var readonly = new Readonly();
        final @Nullable String mutableMsg = "changed mutable";

        readonly.capacity = 10; //error
        readonly.msg = "new readonly"; //error

        readonly.mutableMsg = mutableMsg;

        printMessages(readonly.msg, mutableMsg);

        System.out.println("mutableMsg: " + readonly.mutableMsg);
        System.out.println("capacity: " + readonly.capacity);
        System.out.println("msg: " + readonly.msg);
    }
}

New Additions

JSpecify @NullMarked Annotation Support

  • All Java code generated by JADEx now includes the @NullMarked annotation.
  • This improves Null-Safety along with readonly enforcement.

This feature is available starting from JADEx v0.42. Since the IntelliJ Plugin for JADEx v0.42 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.42 IntelliJ Plugin

We highly welcome your feedback on JADEx.

Thank you.

27
 
 

API-wise, native apps lost to web apps a long time ago. Native APIs are terrible to use, and OS vendors use everything in their power to make you not want to develop native apps for their platform.

28
29
30
 
 

Following in the footsteps of Hashicorp, Hudson, etc. Zed has chosen to cash in the good will of its now substantial user base and start going to full corporate enshittification. Among other things like minimum age nonsense, they have also added binding mandatory opt-OUT arbitration.

I find such agreements very troubling, because it gives up public funded dispute resolution for private which nearly unanimously benefits larger entities, it lowers transparency to near zero, and eliminates the abilities to act as a class and to appeal. But I worry most will just accept it, as is the norm.

You can however opt out by emailing arbitration-opt-out@zed.dev with full legal name, the email address associated with your account, and a statement that you want to opt out.

I'll just consider my days of advocating for Zed as an interesting new editor over and go back to Neovim bliss.

31
32
 
 

Very recently a brand new account commented on my posts with that looked a lot like pictures of my house. The account is @WellWellWaldo@programming.dev, they deleted their account but not the media uploaded.

33
34
 
 

I am using rust, but this applies to many other languages, I get warnings like, dead code, unused variables, and etc, and while I remove most of them, there are some im not sure of, I like running my program and there being 0 warnings, or 0 warnings as i scroll down my code, so for things im unsure of, i mark them so the compiler doesn't put warnings there. I also add comments, starting with TODO:, it has some information about what to think about when i revisit it, also the todo's gets highlighed in my IDE with my extension, but is this bad practice?

35
36
 
 

I'm trying to find a place where you can ask broader development questions, not just specific error messages.

StackOverflow and Codidact are way too restrictive, if your question isn't a precise technical issue with a reproducible example, it gets shut down immediately. Reddit and Lemmy seem more focused on news and memes; actual questions and discussions tend to just sink without engagement. And honestly, the kind of specific error-driven questions StackOverflow excels at are things AI can solve instantly now.

What I'm really looking for is a community (forum, Discord, whatever) where you can get help on broader topics related to software engineering.

Does anything like this still exist? Somewhere with actual humans willing to discuss the process of building software, not just fix syntax?

37
 
 

I teach computer science at Montana State University. I am the father of three sons who all know I am a computer programmer and one of whom, at least, has expressed interest in the field. I love computer programming and try to communicate that love to my sons, the students in my classes and anyone else who will listen.

A question I am increasingly getting from relatives, friends and students is:

Given AI, should I still consider becoming a computer programmer?

My response to this is: “Yes, and…”

38
39
40
 
 

I am trying to write my own string.h functions, my library currently have no dependicies and 11 functions completed. Has basic and readable code to understand. Small binary size. Freely distributable with BSD-3-Clause license. Have a look: mstrutils

41
 
 

How it all started?

Sometimes, there are moments in life then you feel loosing control over your life, when there is to much on a plate and all this overwhelms you, makes you anxious. For me, solution always was to use kind of "get things done" tools, to organize myself. I tried enormous amount of todo apps, even bought a paper todo, but this wasn't enough this time. Every restriction in functionality, every missed feature made me feel I'm loosing control again. And one moment I gave up and decided it is time to make my own tool and make it right (in my understanding), i.e . a todo that is highly customazible and instead of hardcoded features can have any you want. Despite todo app is an anecdote and there are thousands of them, same as with an edit tool microsoft it is quite a challenging task to make a really good one.

Design/Concept

Luckily, I had 2 weeks of winter holidays and I decided to invest this time into this project. I thought a lot on how to make a todo that potentially have any possible feature that anyone can simply add just when they need it. My solution was a Virtual Machine with persistent storage + Tasks that have their own executable instructions. So in this design any todo app could be a simple wrapper around i/o and all functionality would be powered by the virtual machine.

Problems/Complexity

Creation of a working vm is a complex task for sure. I will not mention every problem I had faced during last months, but will just list some features I implemented to solve them:

  • NaN-boxing — All stack values are 64-bit (u64) encoding 6 distinct types (Null, Boolean(TRUE_VAL,FALSE_VAL), STRING_VAL, CALLDATA_VAL, U32_VAL, MEM_SLICE_VAL (offset: 25 bits, size: 25 bits)).
  • InlineVec — Fixed-size array-backed vector implementation used for stack, control stack, call stack, and jump stack with specified limits.
  • Dynamic Memory/Heap — growable Vec heap; memory slices use 25-bit offset and 25-bit size fields (limited by MEM_SLICE_VAL).
  • Definite Loops — DO…LOOP with control stack limit =2 ie 2 nested loops only possible for now.
  • Conditional jump - IF..THEN with jump stack limit =2 ie 2 nested IF..THEN statements only possible for now.
  • Custom binary encoding/decoding implementation.
  • Also vm has zero dependencies.

Current state

My Virtual Machine is still in it's early days and may be missing some important instructions, but already now it can be used for a todo app demo with programmable tasks. All operations — from simple CRUD to the tasks' own instructions — are executed by the virtual machine. The concept in a nutshell is, that any kind of automation or workflow can be enabled by task instructions executed by the VM, rather than hardcoded functions in the app - exactly what I wanted to achieve initially! There are 4 demo task instructions that are not a part of the todo code, but instead are in toml file which could be updated any time with a new one:

  • chain - Creates next task once when another is completed. Removes calldata after call - called once
  • either - Sets complete if either one or another task is completed + deletes not completed task (see gif)
  • destructable - task self destructs when it’s status set to complete
  • hide - Keeps task hidden while specified task’s status is not complete.

Example link: https://github.com/tracyspacy/spacydo/tree/main/examples/todo

When I added the todo example, I realized, that the originally hardcoded states in the VM were a limitation. If I would make them generic (which I did), the Virtual Machine would serve more than just todo apps: new use cases such as tasks orchestration and even state machines became possible. I added a finite state machine primitive example as well - a traffic light - where task is a simple state machine which has own state transition rules in calldata that executes each task's instructions call.

Example link: https://github.com/tracyspacy/spacydo/tree/main/examples/traffic_light

I'm still working on this project alone and struggle to get other people involved to help me stabilize and finalize the VM.

Anyway, this journey is interesting and insightful, and I'm curious what comes next.

42
43
 
 

Sample with fibonacci:

⍥◡+9∩1 is the fibonacci in this language

44
 
 

I'm currently using a pagination, link extraction, and Python filtering process before feeding links to fichub-cli to download all stories from a specific forum. The workflow is detailed in this post: https://piefed.zip/post/1151173 . Looking for a more streamlined, possibly one-command solution that could crawl the forum, extract thread links, and download them automatically. Any suggestions?

45
 
 

I have created a tech content platform with thousands of tech feeds from individual bloggers, open source projects and enterprises.

The content is organised into spaces. In the Programming space, you can find the latest programming related articles. Each space is filtered by topic and with the threshold parameter you can even control the filtering.

The site has many more features that you can explore.

There is also an RSS feed that you can subscribe to:

https://insidestack.it/spaces/programming/rss

46
 
 

JADEx (Java Advanced Development Extension) is a safety layer that runs on top of Java.
It currently supports up to Java 25 syntax and extends it with additional Null-Safety and Immutability features.

In the previous article, I introduced the Null-Safety features.
For more details, please refer to:


Introducing the New Immutability Feature

If Null-Safety eliminates runtime crashes caused by null,
Immutability reduces bugs caused by unintended state changes.

With v0.41 release, JADEx introduces Immutable by Default Mode


Core Concepts

The Immutability feature revolves around two simple additions:

apply immutability;
mutable

apply immutability;

  • When you declare this at the top of your source file:

    • All fields
    • All local variables (excluding method parameters)
    • are treated as immutable by default.
  • When the JADEx compiler generates Java code:

    • They are automatically declared as final.

mutable keyword

  • Only variables declared with mutable remain changeable.
  • Everything else (excluding method parameters) is immutable by default.

JADEx Source Code


package jadex.example;

apply immutability;

public class Immutability {

    private int capacity = 2; // immutable
    private String msg = "immutable"; // immutable

    private int uninitializedCapacity; // uninitialaized immutable
    private String uninitializedMsg; // uninitialaized immutable

    private mutable String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

Generated Java Code

package jadex.example;

//apply immutability;

public class Immutability {

    private final int capacity = 2; // immutable
    private final String msg = "immutable"; // immutable

    private final int uninitializedCapacity; // uninitialaized immutable
    private final String uninitializedMsg; // uninitialaized immutable

    private String mutableMsg = "mutable";  // mutable

    public static void main(String[] args) {
        final var immutable = new Immutability();

         immutable.capacity = 10; //error
         immutable.msg = "new immutable"; //error

         immutable.mutableMsg = "changed mutable";

        System.out.println("mutableMsg: " + immutable.mutableMsg);
        System.out.println("capacity: " + immutable.capacity);
        System.out.println("msg: " + immutable.msg);
    }
}

This feature is available starting from JADEx v0.41. Since the IntelliJ Plugin for JADEx v0.41 has not yet been published on the JetBrains Marketplace, if you wish to try it, please download the JADEx IntelliJ Plugin from the link below and install it manually.

JADEx v0.41 IntelliJ Plugin

We highly welcome your feedback on the newly added Immutability feature.

Finally, your support is a great help in keeping this project alive and thriving.

Thank you.

47
 
 

I just read how someone on RetroArch tries to improve documentation by using Copilot. But not in the sense as we might think. His approach is to let Copilot read the documentation and give him follow-up question a hypothetical developer might have. This also could be extended to normal code I guess, to pretend it being a student maybe and have it ask questions instead generating or making changes? I really like this approach.

For context, I myself don't use online Ai tools, only offline "weak" Ai run on my hardware. And I mostly don't use it to generate code, but more like asking questions in the chatbox or revising code parts and then analyze and test the "improved" version. Otherwise I do not use it much in any other form. It's mainly to experiment.

48
49
 
 

I'm looking for advice on building a collaborative caching system for APIs with strict rate limits that automatically commits updates to Git, allowing multiple users to share the scraping load and reduce server strain. The idea is to maintain a local dataset where each piece of data has a timestamp, and when anyone runs the script, it only fetches records older than a configurable threshold from the API, while serving everything else from the local cache. After fetching new data, the script would automatically commit changes to a shared Git repository, so subsequent users benefit from the updated cache without hitting the server. This way, the same task that would take days for one person could be completed in seconds by the next. Has anyone built something like this or know of existing tools/frameworks that support automated Git commits for collaborative data collection with timestamp-based incremental updates?

50
view more: ‹ prev next ›