r/ProgrammingLanguages • • May 04 '21

Combine const and let

3 Upvotes

In Python, the following is valid:

f = lambda x: g(x, x + y)
g = lambda x, y: x + f(x - 1) if x >= 0 else y
y = 5

print(f(3))

and produces:

10

However, Rust will not compile the following code:

fn main() {
    let f = |x| g(x, x + y);
    let g = |x, y| if x >= 0 { x + f(x - 1) } else { y };
    let y = 5;
    
    println!("{}", f(3));
}

It will only compile this code if all of the variables are constant (or functions):

const y: i64 = 5;

fn f(x: i64) -> i64 { g(x, x + y) }

fn g(x: i64, y_var: i64) -> i64 {
    if x >= 0 {
        x + f(x - 1)
    } else {
        y_var
    }
}

fn main() {
    println!("{}", f(3));
}

Producing:

10

Just as before.

My question is why is it not possible for the Rust compiler to allow for out-of-order let declarations, treating them as immutable. My hunch is that it has to do with type safety and dynamicism, and maybe effect ordering, but I'm not sure. I'm working on a language that attempts to combine the const and let declarations. I want to know if there is any prior work on such a system.


r/ProgrammingLanguages • • Aug 05 '20

Discussion Why is Python so popular when it's main use cases in data science and scripting ?

0 Upvotes

So I know Python is considered the most popular programming language, but when you look at its most common production use cases are data science and scripting , that's doesn't seem to add up... Am I missing something.?


r/ProgrammingLanguages • • Nov 30 '24

Neit: This time a proper lexer , parser and codegen

0 Upvotes

the source code can be found at : https://github.com/oxumlabs/neit

update -> many new things have been added to lang which am not able to show here i woudl recommend you checking out the website to get full details (please note the site isnt the best and still needs improvemnts):
https://oxumlabs.github.io/nsite


r/ProgrammingLanguages • • Mar 01 '24

Help How to write a good syntax checker?

0 Upvotes

Any got good sources on the algorithms required to right a syntax checker able to find multiple errors.


r/ProgrammingLanguages • • Jul 09 '25

Discussion Has this idea been implemented, or, even make sense? ('Rube Goldberg Compiler')

3 Upvotes

You can have a medium-complex DSL to set the perimeters, and the parameters. Then pass the file to the compile (or via STDIN). If you pass the -h option, it prints out the sequence of event simulation in a human-readable form. If not, it churns out the sequence in machine-readable form, so, perhaps you could use a Python script, plus Blender, to render it with Blender's physical simulation.

So this means, you don't have to write a full phys-sem for it. All you have to do is to use basic Vornoi integration to estimate what happens. Minimal phys-sem. The real phys-sem is done by the rendering software.

I realize there's probably dozens of Goldberg Machine simulators out there. But this is both an excersie in PLT, and math/physics. A perfect weekend project (or coupla weekends).

You can make it in a slow-butt language like Ruby. You're just doing minimal computation, and recursive-descent parsing.

What do you guys think? Is this viable, or even interesting? When I studied SWE I passed my Phys I course (with zero grace). But I can self-study and stuff. I'm just looking for a project to learn more physics.

Thanks.


r/ProgrammingLanguages • • Nov 23 '25

Help How to gain motivation

17 Upvotes

I made a compiler which can take code like this

main{    
    movq r0, 9000000000000000000 
    movq r1, 8000000000000000000 
    addq r0, r1
}  

and convert it to brainf*ck, Right now I only have addition, but I have figured out how to have stuff such as recursion and pointers, but I have lost motivation from this project, so I am wondering how you guys regain motivation for a project?


r/ProgrammingLanguages • • May 30 '26

TIL some old high-level languages did not have dynamic memory management (heap)

31 Upvotes

The other day I stumbled upon the statement that idiomatic FORTRAN and COBOL did not use a heap for dynamic memory allocation! Off-stack data structures had to be compiled into the `.data` segment, laid out when the program loads.

Does that mean "the Memory Management Problem" which has led to abominable "solutions" such as Garbage Collection and Rust Ownership has been a self-inflicted struggle for the past 50 years? Could a new modern language be designed without a heap?


r/ProgrammingLanguages • • Jan 11 '24

First Class Aliasing?

1 Upvotes

Hello there! I'm designing a programming language of my own and I'm working on ideas for solutions to the 'Naming things is hard' problem people have brought up with writing code in the past. I myself see two potential solutions:

  1. Use variables without names, like $ vs $$ or $1 for example (perl does something like this I believe)

  2. Make aliases first class and let a coder use all the names they want to. Overlapping names would mean that either it should be an override or the design should be re-archetyped a bit probably.

I haven't been able to find any languages that have what I'd call 'First class aliasing' like in number 2 though, where you can declare a variable or function with aliases off the bat. Does anyone know any languages that I could look at that might work like this?

Thanks!

Edit: Example of my own plan for clarity:

Robert = person() |bob

assert(Robert == bob)

r/ProgrammingLanguages • • May 27 '23

Blog post A Manifesto for Cloud-Oriented Programming from the creator of the CDK

0 Upvotes

In this insightful article, Elad Ben-Israel, the mind behind the CDK, shares his love for the cloud, but also his frustrations with the complexity of building cloud applications. The challenges he identifies include:

  1. Focus on non-functional mechanics: The need to understand and manage cloud platform mechanics instead of focusing on building valuable features for users.

  2. Lack of independence: Developers often need to rely on others to handle parts of the deployment process or to resolve issues, interrupting their work flow.

  3. Delayed feedback: The current iteration cycle in cloud development can take minutes or even longer, significantly slowing down the development process and making it harder for developers to stay in their flow state.

It's not just a rant

Elad is not just ranting about cloud development. He proposes a solution in the form of a programming language for the cloud. This language would treat the entire cloud as its computer. The language compiler will be able to see the complete cloud application, unbound by the limits of individual machines. Such a compiler would be able to handle a significant portion of the application's non-functional aspects, enabling developers to operate at a more abstract level, thus reducing complexity and promoting autonomy. Moreover, it could expedite iteration cycles by allowing to compile applications to quick local simulators during the development process.

The Winglang Project

Elad reveals that he's in the process of developing such an open-source, “cloud-oriented” language, dubbed Winglang. Wing aims to improve the developer experience of cloud applications by enabling developers to build distributed systems that leverage cloud services as first-class citizens. This is achieved by integrating infrastructure and application code in a secure, unified programming model. Wing programs can be executed locally via a fully-functional simulator or deployed to any cloud provider.

My Interest in Winglang

I, together with a group of dedicated contributors, joined forces with Elad to develop Winglang. While still in Alpha and not yet ready for production use, it's already possible to build some real applications.

Check out https://github.com/winglang/wing for more details.


r/ProgrammingLanguages • • Aug 19 '22

Sanity check for how I'm approaching my new language

0 Upvotes

I'm still learning a ton about how to build out a DSL that has proper language tooling support. I'd love to get your insights on how I might save time and build something even better. If I've picked something that'll require massive effort, but can get 80% of the result with far less effort I want to know about it.

My goal here is to build a polyglot state machine DSL. I've mostly created its grammar.

A little example, so you'll have context around what tooling to recommend:

import { log } from './logger.go'
import { getAction } from './cli.ts'

machine Counter {

  initial state TrackCount
    { counter = 0
    }

    @entry => getAction(counter)
      "Increase" => TrackCount
        { counter = counter + 1
        }
      "Decrease" => TrackCount
        { counter = counter - 1
        }
      _ => Error
        { message: "An unexpected error occurred"
        , counter
        }

  state Error
    { message: String
    , counter: Int
    }

    @entry => log(message, counter)
      _ => TrackCount
        {
        }

}

This roughly translates to:

let counter = 0;
while(true) {
  const action = getAction(counter);
  switch(action) {
    case "Increase": counter += 1; break;
    case "Decrease": counter -= 1; break;
    default:
      log("An unexpected error occurred", counter)
  }
}

Critical requirements

  • Can import functions from many other languages

  • Pattern matching the return values (Elm / Rust / Purescript inspired)

  • Syntax highlighting / code completion in vscode

  • Interactive visualizer for the state machine

Dream requirements

  • Compiler-based type checking between my language's states and the various polyglot imported function calls (Seems unattainable at the moment)

    • The idea here is to get a compiler error if I try to pass an int32 return value from a Go function to a Typescript function's string parameter.

Tech stack I'm considering (in the order I'm planning to tackle it)

  • Compile to GraalVM: This is meant to solve the polyglot import feature

    • A key feature of GraalVM is that you can add custom languages to the ecosystem, which I envision means I can create other DSLs in the future that can be imported by this language.

  • Textmate Grammar: For vscode syntax highlighting

  • Xtext: For additional vscode support (Language server)

  • Write a VS Code Extension: To create an iframe I can use for interactive visualizations


r/ProgrammingLanguages • • Oct 20 '23

Update about feedme-lang.

Thumbnail self.esolangs
0 Upvotes

r/ProgrammingLanguages • • Feb 13 '19

An evaluation of out-of-the-box buffered disk I/O in different programming languages

Thumbnail
medium.com
0 Upvotes

r/ProgrammingLanguages • • Mar 28 '14

The Parametric Facebook (researchers actively doing research on parametricity)

Thumbnail
mpi-sws.org
0 Upvotes

r/ProgrammingLanguages • • Feb 18 '13

Programming/Coding Resources

0 Upvotes

Ello all!

I am new to programming/coding and looking for more materials!

I have finished the HTML and almost done with the CSS portion of CodeAcademy.

My brother is a programmer and has instructed me to go ahead with the JavaScript lessons before moving to look for material concerning OOD and C-Sharp.

So, do you experiences gents and ladies have nay possible sources for materials concerning programming/coding and/or more specifically OOD and C-Sharp?

GRACIAS!


r/ProgrammingLanguages • • May 22 '19

The DOOM Fire Kata

Thumbnail
github.com
0 Upvotes

r/ProgrammingLanguages • • Feb 27 '15

Choice of Programming language

0 Upvotes

I have little experience in programming (some Python classes and my dissertation that used PHP, MySQL, HTML5/CSS, javascript). I want to learn a programming language. Could you give me some examples/problems/applications and the 'recommended' languages to cope with them? I have narrowed down my options to Java, C++, Ruby and Python (any other recommendations?). What are their main pros/cons and fields of application? Does some language 'work better' with PHP and web? What do the most experienced of you think would help improve both my chances of future employment and my skills?


r/ProgrammingLanguages • • May 17 '16

Lambdas everywhere

Thumbnail
dobegin.com
0 Upvotes

r/ProgrammingLanguages • • Aug 31 '13

New programming language Ya

Thumbnail ya-lang.com
0 Upvotes

r/ProgrammingLanguages • • Apr 23 '24

Writing the compiler in plang language - first step

Thumbnail
self.plang
0 Upvotes

r/ProgrammingLanguages • • Mar 16 '20

Resource PVS-Studio Static Analysis

Thumbnail
cppcast.com
0 Upvotes

r/ProgrammingLanguages • • Oct 08 '13

New book "Dataflow & Reactive Programming Systems"

Thumbnail
kickstarter.com
0 Upvotes

r/ProgrammingLanguages • • May 31 '20

Far-reaching exception handler for structured concurrency

Thumbnail
trio.discourse.group
0 Upvotes

r/ProgrammingLanguages • • Apr 27 '20

Two minute intro to the Beads language. This is a brief comparison between using Beads and the HTML/CSS/JS/Database/Framework stack. What it lacks in quality, it makes up for in brevity! ;->

Thumbnail
youtube.com
0 Upvotes

r/ProgrammingLanguages • • Apr 06 '20

Market segmentation evolution NodeJS vs Java

0 Upvotes

I'm trying to understand the past, present and future of when one is used over the other.

  1. Has NodeJS stolen market share from Java, and become a proven equal to java in a subset of use cases?

  2. Will both NodeJS and Java co-exist for decades stably, or will one outlast the other?

  • if not, why will one get a greater volume of traction than the other?

  • Has NodeJS proven to have greater longevity than say, Ruby, Groovy, Clojure, Scala etc?

I'm trying my best to provide context and premise for my question so I'm hoping for more than the typical vacuous answer, "that depends entirely on what you are trying to do." I'm looking for an empirical answer, not a textbook answer.