4 ms·
>Quick, name a language where I can do something simple like mention "Whenever this function is called, make sure there is enough free memory (at least ---- MB)
by coldtea 10y ago
>Quick, name a language where I can do something simple like mention "Whenever this function is called, make sure there is enough free memory (at least ---- MB) before actually calling it; if there isn't, first swap out any objects from memory to disk, starting with the ones that had been used the longest time ago, and after the function has finished running, swap those back into memory."
The first fallacy is thinking that this is "simple" merely because it is "well specified".
The second fallacy is thinking that this should be the task of a language.
- Turing_Machine 10y ago"The second fallacy is thinking that this should be the task of a language." Yes. This should be the job of the OS, not the programming language.
- logicallee 10y agoIn my opinion a language should do whatever I want. And in the future languages will.
- inimino 10y agoBy the time languages have the DWIM feature, AI already took the whole job.
- logicallee 10y agoThis is very insightful. I'll let AI take the whole job, if it means it will just do whatever I want after. Small loss if that means lots of programming jobs disappear.
- coldtea 10y agoYour opinion is more about magic than computer science.
- logicallee 10y agoYou know the quote I'm going to put here :)
- logicallee 10y agoHey you're right, a language shouldn't let me just describe what my executable should do - and then give me that executable. My mistake! A language should just be a super tiny syntactic framework that elegantly lets library writers rewrite the same thing they already wrote in C++, Python, Perl, Go, Java etc libraries for - but this time in my language! It shouldn't really "do" anything. Who needs a programming language with any abilities! That's not what languages are for! /s
- vidarh 10y ago> A language should just be a super tiny syntactic framework that elegantly lets library writers rewrite the same thing they already wrote in C++, Python, Perl, Go, Java etc libraries for - but this time in my language! The rewrite issue is exactly why it makes sense to avoid putting things in the language if it doesn't need to be part of the language. Consider that a more generic way of offering what you suggest is to punt most of it to the OS and have the language/runtime instead "just" offer you a way of having it pre-allocate sufficient space from the OS. Many do in some way or other, either by getting out of the way (e.g. C, C++, any other language with "manual" memory management) or by offering switches or known behaviour to coerce the allocators to act how you want (e.g. in most VM based languages you'll find options to tune the allocation/GC patterns in various way). In practice there are ways of doing what you want in most language/OS combinations, if not always as cleanly as you might like. If you want functionality like that as part of the language, a more flexible approach would be to e.g. do things like support cross-cutting (effectively inserting hooks before/after function/method calls) or method/function aliasing and provide a means to switch out the object/memory allocator. Doing so would be far more generic, and would allow the functionality you want to be written as library code instead of adding specialised language construct for a specific memory allocation strategy.
- Samis2001 10y agoHere's the problem with that idea: How do you convert your abstract high-level description into a set of specific operations? First you need to parse your specification, and parsing natural language is already hard. Secondly, you have to infer everything else that was requested and will be needed but was not originally specified. Alright, now you have your list of requirements. Firstly, you must break each requirement down into a long series of small steps that perform exactly one operation - such as add 1 and 1 together. You must also find the correct order for all of the steps, as well as the operations to store and manage all required data in memory as meeded. Finally, the list must either be translated to the native language of your computer's CPU or ran by a program running on the CPU. As you can see, this is actually a large and difficult task, even if you manage to not encounter any unsolvable problems along the way. I would think the following comes naturally: The difference between your language and the 'dumb-as-rocks' ones is that the latter are implementable and usable.