Comments (23)
I'm not suggesting SPARK or Ada to be included.
I think, because BASIC was easy to learn and hard to make dangerous mistakes in, and the book was influential to beginning programmers, that you want those same traits in the selected modern languages. What we are trying to say is that "memory safe scripting languages" is not a very good description then. So why not make the requirement "a language that is easy to learn and hard to make dangerous mistakes in"? Then all currently selected languages can stay including Pascal, and C/C++ stay out.
OTAH, I might be misunderstanding the objective of the project completely...
from basic-computer-games.
Oh my bad, I assumed it was! Are there version of Pascal which are memory safe?
from basic-computer-games.
I mean, in what sense? It's hard to explain, but basically both Delphi and Free Pascal (as I was using in that link) are like:
Classes
are pure "reference" heap-based types sort of similar to say D or Swift classes (minus any kind of implicit reference counting or garbage collection)Objects
are roughly equivalent to C++ classes in their support for inheritance (though it's just single inheritance) and ability to be either stack or heap allocatedRecords
are basically just like C++ structs or classes, except with no support for inheritance
There's various things about the overall language that make it generally more safe than something like C or C++ in most cases in practice, contextually, but also nothing stopping you from doing dangerous things with raw pointers / inline assembly / etc whenever you want, if that makes sense.
from basic-computer-games.
Pointers in Pascal are type safe; i.e. a pointer to one data type can only be assigned to a pointer of the same data type. Also pointers can never be assigned to non-pointer variables. Pointer arithmetic (a common source of programming errors in C, especially when combined with endianness issues and platform-independent type sizes) is not permitted in Pascal. All of these restrictions reduce the possibility of pointer-related errors in Pascal compared to C, but do not prevent invalid pointer references in Pascal altogether. For example, a runtime error will occur if a pointer is referenced before it has been initialized or after it has been disposed.
If we really can't define Pascal as a memory safe language, I'm fine dropping it and replacing it with one that is truly memory safe..
from basic-computer-games.
Again, it depends on what you mean. Pascal as described in that article lacks many features added later in various different implementations, though generally yes, is type-safer than C. Note that there's no "Pascal standard" that anyone cares about currently, different parties just extend it however they see fit.
At the broadest level though (in current "Object" Pascal implementations, specifically) there is no garbage collection or automatic memory management of any kind other than in a couple of specific cases for specific types, such as the "magic" compiler-implemented strings and dynamic arrays that it has (which are atomically reference counted in a way that requires nothing on the programmer's side).
That's basically what I was mostly getting at here, originally.
from basic-computer-games.
Hmm. Looks like we need to drop Pascal in favor of a different language.. since we agreed to include Kotlin, maybe Kotlin replaces it? Google gave Kotlin a big boost:
https://developer.android.com/kotlin
from basic-computer-games.
Looks like we need to drop Pascal in favor of a different language.
Might I suggest D? (Tongue in cheek) Seriously though, I am professionally involved in porting half a million lines of Pascal code to D. D is a fitting successor to Pascal (as well as to C++, Python; Basic...)
I just pushed changes to #365 that should guarantee memory-safety.
from basic-computer-games.
from basic-computer-games.
D is not really memory safe
Neither is Kotlin. D already has the features that are proposed in that post, nota bene.
from basic-computer-games.
At the broadest level though (in current "Object" Pascal implementations, specifically) there is no garbage collection or automatic memory management of any kind other than in a couple of specific cases for specific types, such as the "magic" compiler-implemented strings and dynamic arrays that it has (which are atomically reference counted in a way that requires nothing on the programmer's side).
I don't know if you count Interfaces as "couple of specific cases", but they are reference counted.
from basic-computer-games.
We'll have to go back to the TIOBE top languages list and decide which one we want to replace with. Them's the rules..
from basic-computer-games.
That's fine if that is the rule you want to have. The value of that index is frequently questioned though (see Wikipedia and plenty other places) and especially once you get into the promille range, noise gets more prominent in the ranking.
But since it's you who is setting the rules, you can also just say Pascal stays in because I like the language (and because all the work has been done). Is there any downside to including other languages, and expand the opportunities for learning?
from basic-computer-games.
Well, I do believe very strongly in the languages being FULLY memory safe, so I want to stick with that..
from basic-computer-games.
I don't know if you count Interfaces as "couple of specific cases", but they are reference counted.
That's true I guess yeah, although Free Pascal at least has a compiler directive that makes them not (which is quite useful in some cases, though generally I don't use interfaces that much, or even classes that don't implement any interfaces these days for that matter, preferring "extended records" most of the time).
Can't remember if a similar directive is available in Delphi.
from basic-computer-games.
I'm still torn on what to do here and could use advice. I feel VERY STRONGLY we want only absolutely safe languages (in the official list of languages, I mean), no exceptions.
For people who want to contribute C or C++ versions (or any other memory unsafe language) that is also fine, but those must be linked from the readme.md.
from basic-computer-games.
I'm still torn on what to do here and could use advice. I feel VERY STRONGLY we want only absolutely safe languages (in the official list of languages, I mean), no exceptions.
For people who want to contribute C or C++ versions (or any other memory unsafe language) that is also fine, but those must be linked from the readme.md.
Frankly, I think a larger oddity with your original list is moreso that you included languages that are fully memory safe, but still are absolutely not "scripting languages" by any metric I'm aware of (notably C#, VB.NET, and Java, for example).
from basic-computer-games.
I am afraid there is a need for nuance when talking about safety.
- Java has an unsafe escape hatch.
- C# has an unsafe escape hatch.
- Python is not "absolutely memory-safe".
- Ruby and Perl have had vulnerabilities.
It appears to me that the linked-to unsafe Delphi code requires the {$PointerMath On}
pragma, from which one might conclude that code that does not include that pragma cannot do unsafe sings that require pointer arithmetic. Given that Pascal can do array bounds checking, I think the way in which Pascal is used to port these BASIC examples is very safe.
from basic-computer-games.
Also, from your Pascal Wikipedia quote:
... but do not prevent invalid pointer references in Pascal altogether. For example, a runtime error will occur if a pointer is referenced before it has been initialized or after it has been disposed.
A runtime error does not mean the program is memory-unsafe. An error due to memory-unsafety causes undefined behaviour, including the program continuing with wrong results, or affecting other parts of the system. That's not the case here. If the program is terminated due to a memory error then that is considered a safe outcome!
from basic-computer-games.
Also, from your Pascal Wikipedia quote
TBH, you really can't define "Pascal" by what Wikipedia has to say in reference to what sounds like an implementation from around 35 - 40 years ago. The closest you can get to accurate nowadays is "literally whatever the developers of Delphi and / or Free Pascal happen to decide to implement at any given time".
Given that Pascal can do array bounds checking, I think the way in which Pascal is used to port these BASIC examples is very safe.
Yeah, I could 100% write "safe" Pascal implementations of pretty much anything, sure. I wasn't saying I couldn't, just pointing out that it was actually a language that isn't strictly safe by nature and in fact simultaneously provides both high-level and low-level features in a sort of uncommonly blunt way.
from basic-computer-games.
"literally whatever the developers of Delphi and / or Free Pascal happen to decide to implement at any given time"
True.
I get your point and I agree.
@coding-horror: Drawing a clear line at languages that are absolutely safe is problematic because safety is not a clear cut concept. Even Ada is not completely safe, otherwise SPARK would not need to exist. [Edit: And even SPARK comes at different levels of rigour.] What do you actually mean with "memory-safe scripting languages"? I think you actually want languages that are suitable for beginners, that are quick to get going with and that help you from making programming mistakes to a reasonable degree. Because even though SPARK may be the safest language in existence, nobody would ever recommend SPARK to a beginning programmer because [s]he would not get things done (let alone afford the license fees).
from basic-computer-games.
Well SPARK isn't in the top 20 TIOBE languages, is it? That's another inclusion criteria we care about.. this isn't an exercise in speaking forgotten languages, or languages nobody (statistically speaking) uses..
https://www.tiobe.com/tiobe-index/
from basic-computer-games.
a language that is easy to learn and hard to make dangerous mistakes in
That seems fine!
from basic-computer-games.
I've updated the official languages to 10:
- C#
- Java
- JavaScript
- Kotlin
- Lua
- Perl
- Python
- Ruby
- Rust
- VB.NET
Rationale is here https://discourse.codinghorror.com/t/updating-101-basic-computer-games-for-2022-and-beyond/7927/116
from basic-computer-games.
Related Issues (20)
- terminal_style.css pegs cpu usage HOT 1
- Mastermind.py has trouble counting black and white pegs. HOT 5
- Typo in the Basic and JavaScript versions of SALVO HOT 2
- hangman.rb doesn't randomize the order of puzzle words HOT 9
- Are less mainstream languages allowed? HOT 4
- DEC Basic Computer Games HOT 2
- A little more about the spirit of the project??? HOT 6
- Super Star Trek README has a typo that's a rude word. HOT 1
- Edited latest commit requesting review for pull request (Life for Two.py)
- Super Star Trek - Ship class does not work correctly HOT 2
- A function never called in tictactoe2.py HOT 1
- Hacktoberfest HOT 1
- Confusion between 91_Train and 92_Trap Rust HOT 3
- 84_Super_Star_Trek java issues HOT 1
- Lunar lander initial weight HOT 1
- Battle doesn't seem to accept the num,num format suggested in the readme HOT 4
- Python Acey-Ducey has a "1" card instead of the "10" HOT 5
- Code decomposition question HOT 4
- Another possible tourist trade bug in King HOT 2
- Hacktoberfest
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basic-computer-games.