4,482 karma · joined Sep 28, 2012 (14y ago) · 2,100 submissions
I hope the spam filter will respect it!
comment 3y ago · link · parent
With this code:
indent(1)
indent 2
if x<0:
function 1
function 2
function 3
if you select the if block starting the selection at the "if" (i.e. ignoring the whitespace at its left) up to function 3, and paste it right under indent(1), it produces the following: indent(1)
if x<0:
function 1
function 2
function 3
indent 2
if x<0:
function 1
function 2
function 3
Yet if you select the whole line including the initial indentation whitepace and paste it at the same place under indent(1), then it doesn't change the block indentation: indent(1)
if x<0:
function 1
function 2
function 3
indent 2
if x<0:
function 1
function 2
function 3
That looks sensible to me; if you're moving whole lines it will paste them unchanged, but if you move the cursor to select specifically a keyword and its context, it treats it as a code block, reformatting its indentation to that of the place where you are pasting it.comment 3y ago · link · parent
Maybe, as long as you're aware that this is the same kind of correctness that you get from looking at Google's first search results (the old kind of organic pages, not the "knowledge graph", which uses an different process - precisely to avoid being spammed by SEO) i.e. "correctness by popularity".
This means that the content that is more replicated will be considered more true by the system, regardless of its connection to reality or its coherence with the rest of the knowledge in the system. And you know what they say about big enough lies that you keep repeating millions of times.
comment 3y ago · link · parent
Of course it can do it. Indentation changes are parsed as delimiters, so it can treat them in the same way as if you put those delimiters yourself by hand.
> And yet, I don't have to worry about that error because the editor is able to simply autoformat it so I can see where the error is even when the compiler/interpreter thinks it's legal code!
Nothing prevents an IDE to highlight that error through other means. Ever heard of secondary notation? You don't need explicit delimiters to apply them, when indentation changes work as delimiters themselves. Simply highlight the start and end of blocks, and you'll get the same exact benefits as with programming languages based in brackets.
> These errors, which can be automatically found by the computer in other languages,
So tell me, how would the computer find an error if you have unmatched open/closed brackets? Doesn't that mean that other computer languages have errors that can't exist in Python?
> Your example is one of a burden that falls to the programmer in Python, but is taken care off by the computer in other languages.
How does an error in C code fall to the programmer of Python?
BTW, do you understand Python block delimiters at all? Your complaint seems to come from not understanding how a Python developer sees indentation. Once you enter this mindset, indentation errors are no different than unmatched open/close brackets - which do exist in languages like C too.
> That's the whole point - using whitespace as part of the code means that the IDE can not, and never will be able to, autoformat the code.
No - it means that indentation changes are meaningful, so the state of the code before reformatting should be maintained after reformatting. As long as the reformat tool doesn't change the meaning of the Python code, it will autoformat code perfectly fine, as numerous autoformatters in existence prove.
https://www.kevinpeters.net/auto-formatters-for-python
Which is what I was referring to in my first comment - you need an IDE that understands Python syntax, not just one that blindly pairs open/close delimiters.
comment 3y ago · link · parent
A proxy for confidence in what exactly?
Language models represent closeness of words, so a high probability would only express that those words are put together frequently in the corpus of text; not that their meanings are at all relevant to the problem at hand. Am I wrong?
comment 3y ago · link · parent
ChatGPT models are language models; they represent closeness between text utterances. It works by looking for the chains of words most similar or usually connected to those indicated in the prompt, with no understanding of what those words mean.
As a metaphor, think of an intern who every morning is asked to buy all the newspapers in paper form, cut out the news sentence by sentence, and put all the pieces of paper in piles grouped according to the words they contain.
Then, the director requests to write a news item on the increase in interest rates. The intern goes to the pile where all the snippets about interest rates are placed, will randomly get a bunch of them, and write a piece by linking the fragments together.
The intern has a PhD in English, so it is easy for them to adjust the wording to ensure consistency; and the topics more talked about will appear more often in the snippets, so the ones chosen are more likely to deal with popular issues. Yet the ideas expressed are a collection of concepts that might have made sense in their original context, but have been decontextualized and put together pell-mell, so there's no guarantee that they're saying anything useful.
comment 3y ago · link · parent
I replied to dismiss your assumption that adding delimiters as '}' or 'END' will ensure the correctness of code in a way that a code with indentation delimiters can't do. It's similar to saying that in, a language where statements are not finished by semicolon, it's not decidable where sentences end, so this forces the developer to decide on the correctness of statements. OF COURSE there are ways to define where a statement ends without adding a semicolon to each one, just like there are ways to decide where blocks end in an indent-based programming language; they are embedded in the language syntax.
Heck, C is notorious for producing incorrect code for NOT using meaningful indentation and relying on delimiters instead. If you write:
if (x>0)
function(1);
else
function(2);
And then you expand the else block: if (x>0)
function(1);
else
function(2);
function(3);
Then function(3) will be compiled out of the if sentence, when it's clearly part of the else block.comment 3y ago · link · parent
> Will it? Are you sure?
Yes, it's defined as part of Python specification. https://docs.python.org/3/reference/lexical_analysis.html#in...
Indentation increasing or decreasing generates INDENT and DEDENT tokens, which are used as block delimiters.
> Remember, we're talking about an IDE automatically figuring out proper indentation for something.
The IDE doesn't need to figure out whether the program is correct. Only has to treat code blocks as defined by the language syntax. In your linked example:
if x > 0:
function1()
function2()
function3()
if x > 0:
function1()
function2()
function3()
The IDE should treat the blocks as if defined with delimiters this way: if x > 0: {
function1()
function2()
function3()
}
if x > 0: {
function1()
function2()
}
function3()
Because that's how Python will interpret them. So, the IDE would do exactly the same behavior with curly bracket delimiters and with changes in indentation, because in both cases there is a precise rule to define where blocks start and end.comment 3y ago · link · parent
If you're talking about failing to determine blocks which are NOT correct Python, then I don't have a problem with those failing to be correctly indented under copy/paste. The vast majority of use cases would still be well served.
comment 3y ago · link · parent
It's not rocket science, just following the language indentation rules for defining blocks. If the language parser can do it, why not the text editor?
comment 3y ago · link · parent
An IDE with proper language support for a whitespace-aware language should be able to parse the AST figuring out the code structure from the indentation level; then it could reformat it at the proper indent level when you copy and paste it elsewhere, just like it does with a delimiter-based language.
comment 3y ago · link · parent
There is a size limit to what language curators are able to maintain, yes.
The idea of the standard library is that it will select components that are general enough to cover a wide range of use cases; therefore the language builders ned time to review every new proposal, and their time is limited.
You may dump everything under the sun in the standard library, but then it won't be better than what you get from a library marketplace.
comment 3y ago · link · parent
I like environments where you can keep visualization aids close to the code to which they apply; nowadays, that means using online notebooks a la Jupyter and ObservableHQ, or at least markdown files with a preview plugin integrated in your IDE. There you can represent diagrams as code, like Graphviz and Mermaid.
I long for the day that those visual representations can be accessed programmatically and used as part of the code itself, like VB6 interactive widgets were created graphically yet usable in the application; e.g. creating state machines visually by representing states and transitions as boxes and arrows, then compiling the diagram to add conditions and access their values from code (there are some libraries doing this in some environments and languages, but I'm not aware of one that is portable to many languages). I think we're really close to that being possible with modern languages.
comment 3y ago · link · parent
I feel the same way. Of course it's easier for visual tasks like this one, but I tend to think of programs developing in space and time as trees and graphs, even for abstract stuff like complex algorithms and data structures.
Though I think most programmers are more language-oriented. It is often hard for me to find the exact syntax required for coding a particular problem which is fully formed in my mind eye as visual steps. Programming languages are oriented to represent each concept with a precise linguistic abstract syntax, instead of representing concrete changes in the program state, and most developers don't seem to mind.
comment 3y ago · link · parent
That's what I meant about every system using a different syntax for what's basically the same functionality.
comment 3y ago · link · parent
Every text editor, shell environment, programming language or desktop application seems to use regular expressions with a syntax which is slightly different to all the others, but not different enough to call it with a different name.
This means that a newbie learning regular expressions will be thrown into an environment where it can learn the basic principles, but the rules it learns are not generalisable to all applications (e.g. do I match an arbitrary string with '*', or '.*' ? Can I reuse matched patterns with (1) or with {1}? Etc.)
A new readable and easy-to-learn syntax that is nevertheless portable may work like markdown, as a simple-yet-universal new way to apply regexp that newcomers may learn with confidence and apply everywhere, replacing all the previous slightly incompatible versions.
comment 3y ago · link · parent
I think it's just around the corner for those types of applications to come back. And surprisingly, they will come hand in hand with note-taking outliners, not your run-of-the-mill no-code or low-code tools.
See for example Obsidian canvas, released this week. I see it as functionally similar to Visual Basic GUI editor, except simpler and easier to edit; and its layout is stored as JSON in a .canvas file. The open-source Logseq is adding similar visual layout templates together with data-recovery primitives.
They just need to add the core interactive data widgets (text field, text area, buttons) and expose the cards to a programming language in a end-user accesible way, and you'll have the power of a visual language, except web-integrated and with a really simple way to add data (the outliner editor).
comment 3y ago · link · parent
Problem is, figuring out most of them depends on having the thorough user manual at hand to read each gauge or button's purpose; AND understanding what that purpose means, which depends on having an engineering education from the same era when they were built.
comment 3y ago · link · parent
Then you haven't been watching harassment on trans and other LGBT people, being told to die in horrible ways (I'm sure you can point to other high-profile people getting that kind of threats, but this one gets such abuse merely for existing).
Fully agree that having public forums gatekeeped by centralized actors deciding what you can communicate is worrisome; we should get distributed ways to announce the existence of your personal publications to people that may be interested in its subject - like like the Usenet newsgroups of old (which are still in operation, but are not known to the general public).
comment 3y ago · link · parent
It doesn't inspire confidence in that their previous stance was truly motivated by their love of the unrestricted diffusion of ideas.
comment 3y ago · link · parent
They are well within their rights to do so, but that's the exact opposite of competing purely in the market of ideas.
1. https://help.twitter.com/en/rules-and-policies/social-platfo...
comment 3y ago · link · parent
Each cell in level N is the stable pattern of gliders arranged into a square shape in the lower level N-1. If you think about it, this is how "objects" in the real world exist - not as an essence of the object, but as a pattern of simpler elements arranged in space-time that we recognize as an object.
comment 3y ago · link · parent
[(x, y) for x in [1, 3, 5] for y in [2, 7, 8] if x < y]
It's a single monolithic expression that builds the list. The choice syntax however represents each generator and each test as separate expressions, which may even be part of different functions. This seems to offer more flexibility. For example (I don't know the exact syntax):
x:=(1|2); y:=(7|8); x<y; result = (x,y)
Here result is bound to the same values as in the comprehensive list; but these values are yield one at a time, instead of being part of a structure that you traverse.
comment 3y ago · link · parent
In logic programming it's known as the "generate and test" pattern, where you declare the tuple and the program logically generates all its possible values, and then tests each value for compliance. The runtime usually will ensure to make this in an efficient way.
P.S. See the definition of the "amb" operator in typical logic programming languages:
comment 3y ago · link · parent
When evaluated, the "if" expression is added to the "knowledge store", so that it will be evaluated when "x" is bound elsewhere, giving "y" the corresponding value (just "1" or just "2", never "(1|2)") only after that.
P.S. See the definition of the "amb" operator in typical logic programming languages:
comment 3y ago · link · parent
When you are building simple structures to iterate upon, it makes sense to use the more readable comprehension syntax, where you define a list or set of items and their desired properties.
Yet this terse syntax makes more sense for logic programming, where a lot of the domain logic is built upon generate-and-test patterns; you define a combinatoric search space which is the enumeration of all base value in pairs (or tuples), and check which ones are kept for the next processing steps. When using this pattern, it's clearer to be able to express the space with the shortest syntax rather than the verbose one.
As for the adequacy and need for the language, I have my own ideas on what's needed for the stated use case, and I do agree with the authors that this kind of language will really be easier to learn for people without a programming background; it looks much more like mathematics than the traditional von-Neumann-architecture, continuation-based languages, and its declarative nature may make it easier to approach without having a full understanding of runtime behavior.