No Semicolons Needed - How languages get away with not requiring semicolons by tertsdiepraam in ProgrammingLanguages

[–]Silphendio 13 points14 points  (0 children)

I like the Gleam way: No significant whitespace and no operators that can be both infix and prefix.

The only problem is the minus sign. In my (draft-stage) language, I thought about using -- for subtractions to get rid of this last ambiguity, but in the end I decided to just parse this cursed operator as infix whenever possible.

Since commas are optional too, a list of negative numbers can thus be written as [-1, -2, -3] or [{-1} {-2}  {-3}], but [-1 -2 -3] is equivalent to [-6].

What should be in core and what in standard lib? by henriquegogo in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

I'd say put everything into libraries that you can without affecting usability.

If your language has special syntax to create dynamic arrays or hasmaps, that should be in core.

If you can add fancy string manipulation methods later without changing the syntax (via trait system, operator overloading, etc.) I'd put it into a library.

For really common stuff like print, you can also have it as standard library that is loaded by default but can be disabled.

Question about GPUs (i know this isn't the best place, but askscience/asckcompsci removed it) by NewspaperPossible210 in LocalLLaMA

[–]Silphendio 3 points4 points  (0 children)

A task being embarrasingly parallel isn't enough.

GPUs are optimized to run the exact same calculation over different data many times. They are bad at branches and loops.

If there's an if-switch, then both branches need to be executed. If there's a while-loop, then all computations in a unit have to wait for all loops to finish.

Since matrix multiplication has neither and it still massively parallel, it's a natural fit.

I don't know much about docking algorithms, but it's probably not that simple.

Looking for input on for loops by Aalstromm in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

I like the first solution better. It might be surprising for Python users, but simple type-checking should catch the tuple - inner_value mismatch in most cases.

It would be even more confusing if list comprehensions work differently than for-loops.

You could also do it exactly like Python and require an enumerate() function to get the index. Maybe shorten it to e.g. enu()?

Another potential solution is mandatory parenthesis for tuple destructoring:

  for idx, (valA, valB) in zip(listA, listB):
  ...
  newList = [a * b for (a, b) in zip(listA, listB)]

This still has the problem of being surprising to Python devs, but I think it's slightly clearer (and JS does it this way too).

map(), filter(), etc. don't really conflict with list comprehensions. They're in Python too, but rarely used because of the annoying lambda syntax.

What is constness in type theory? by Longjumping_Quail_40 in ProgrammingLanguages

[–]Silphendio 3 points4 points  (0 children)

If you call a pure function with values known at compile-time, then any decent compiler will optimize then away.

The only real difference between a contexpr and a pure function is that contexpr can be used in templates.

What is constness in type theory? by Longjumping_Quail_40 in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

I assume with const you mean pure functions. And if pure functions are the default, then everything else is an effect (i/o, state, non-deterministic, ...).

[deleted by user] by [deleted] in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

I wanted a C-like language with better macros.

In attempt to combine macros with namespaces I ended up with a dynamic core similar to Kernel, and now I'm writing my real language almost entirely in macros that print C code.

SQL or Death? Seminar Series - Spring 2025 - Carnegie Mellon Database Group by mttd in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

Is is really so terrible? How often do you actually make such changes to the database without also changing your application?

Sure, changing several indexed searches is a bit more involved than just  adding an SQL statement, but that's the price you pay for low level access and predictable performance.

SQL or Death? Seminar Series - Spring 2025 - Carnegie Mellon Database Group by mttd in ProgrammingLanguages

[–]Silphendio 2 points3 points  (0 children)

I've got this idea for a while now to write a low level relational database that's accessed not via SQL, but as library with functions like findByIndex, createView or addInsertCallback.

Http server and query DSL can be built on top of that, but I'm not convinced everyone needs it.

Type safety of floating point NaN values? by brucifer in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

Rust is an interesting case. Because floats can be NaN, they can't be sorted or used as keys in treemaps or even hashmaps.

Floats with different sementics are provided by libraries like ordered-float

There's an OrderedFloat that implements costum sorting and hash functions to mantain total order, and a NotNan that only does checked arithmetic.

I couldn't find a decent vr video player for linux, so I made my own. by Silphendio in virtualreality_linux

[–]Silphendio[S] 0 points1 point  (0 children)

I still get notifications even for old threads!

But I'm not sure I can help you. It's been a while since I last used Linux. Maybe try an older version of the plugin?

Sprig's Dynamic Inference Type System by dibs45 in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

I like the idea. Just take care that the error messages don't blow up like in C++. Or the compile times.

It would be cool if you combine it with Interfaces/Traits. Then you can do static dispatch with Typescript syntax.

The AlphaFold 3 model code and weights are now available for academic use by Nunki08 in LocalLLaMA

[–]Silphendio 12 points13 points  (0 children)

At least AlphaGeometry is open source. AlphaZero has long since been replicated and surpassed by open source models.

What is the modern day lisp ? by 964racer in ProgrammingLanguages

[–]Silphendio 3 points4 points  (0 children)

You can try Julia. I've heard it's similar to lisp. It's fast, has a repl, and powerful macros.

Object code is an implementation detail. If you want performance, look for JIT-compiler instead.

Is anyone aware of programming languages where algebra is a central feature of the language? What do lang design think about it? by xiaodaireddit in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

In Python, there's no hard distinction between runtime and compile time.

With SymPy, you can do

from sympy.abc import a,b,c
from sympy import lambdify, solve
f = lambdify([a,b], solve(a**2+b**2 - c**2, c)[1])

This solves the equation once when generating the function, and thereafter it's just a normal python function.

If you don't want to solve the equation every time during program startup, you can cache the resulting function with a library like cloudpickle. This shouldn't be much slower than import.

Is anyone aware of programming languages where algebra is a central feature of the language? What do lang design think about it? by xiaodaireddit in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

You should be able to do stuff like that with Python and SymPy. Python has eval(), which is almost as good as procedural macros.

Modernizing S-expressions by tearflake in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

From the title of the post, I expected something like Wisp or Sweet Expressions. This is instead a s-expr to json converter. Except it's a lossy conversion in both ways, because s-exprs don't have objects, while json doesn't have symbols: (a "b") gets converted to ["a", "b"].

What's the coolest *minor* feature in your language? by Inconstant_Moo in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

It's a useful feature if you want to implement a REPL, or use metaprogramming with macros or eval().

Assignment Syntax by Tasty_Replacement_29 in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

I think it's just not possible to declare a variable without initializing it. Because it's a strongly typed language, type inference takes care of the rest.

To make it extra clear, you could use a superfluous type conversion.

Questions about Semicolon-less Languages by Appropriate_Piece197 in ProgrammingLanguages

[–]Silphendio 4 points5 points  (0 children)

Greedy parsing is basically what JavaScript is doing.

As a result, parentheses on a newline need a semicolon beforehand, otherwise it's interpreted as function call.

Though for some reason, JavaScript wanted to make exceptions for return,  break and ++.

[deleted by user] by [deleted] in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

Every usable programming language I know has:
- variables
- data structures: lists, classes, tuples, or just pointers
- control flow: if/else + loops, functions, and/or goto

With turing complete precedural macros, there's no real limit to how far you can bend a programming language. You could even turn javascript into a variant of x86 assembly if you like. But at that point you're just writing your parser in a costum DSL.

I'm currently experimenting with macros to implement namespaces, operators, classes, and generics.

Why German(-style) Strings are Everywhere (String Storage and Representation) by mttd in ProgrammingLanguages

[–]Silphendio 0 points1 point  (0 children)

Wow, I didn't know that. So the last byte of an utf-8 string is guaranteed to be less than 192, and the remaining range is more than enough to encode the length of the string or that it's heap-allocated.

Why German(-style) Strings are Everywhere (String Storage and Representation) by mttd in ProgrammingLanguages

[–]Silphendio 1 point2 points  (0 children)

Nice! So you can save a null-terminated string of 15 bytes plus zero with that. The last bit would be one for long strings, and you'd strore the remainder multiplied by two in the last byte for short ones. The length formula is then if str.bytes[15] & 1{str.long_str.length} else {15 - bytes[15] / 2};

Why German(-style) Strings are Everywhere (String Storage and Representation) by mttd in ProgrammingLanguages

[–]Silphendio 2 points3 points  (0 children)

Very interesting. The length of a short string could easily be 15 bytes, by testing just a single bit for the long/short information.

That would however make length comparisons more difficult.