Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38379 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2020-04-27 23:52 -0700 |
| Last post | 2020-04-28 10:53 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.javascript
General programming question Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-04-27 23:52 -0700
Re: General programming question Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-04-27 23:57 -0700
Re: General programming question JJ <jj4public@vfemail.net> - 2020-04-28 14:39 +0700
Re: General programming question "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-04-28 10:55 -0700
Re: General programming question Arno Welzel <usenet@arnowelzel.de> - 2020-04-28 21:18 +0200
Re: General programming question "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-04-28 10:53 -0700
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-04-27 23:52 -0700 |
| Subject | General programming question |
| Message-ID | <550b935c-bd30-46bb-be47-df1a7c7cb13c@googlegroups.com> |
I have a question not Javascript related, i understand it probably should be done in assembler or machinecode, but i am just not up to it so i look for alternatives.
What programming language do have fast read write IO to file?
It need to be able to read write continous, but not synchronus("half duplex"?)
And there is no need for multiple threads read and write to same file, just a single thread at half duplex "finding position and inserting".
Could python, do this in an efficient manner?
Or should i use C?
It is also a question about searching within the file at fastest speed possible.
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2020-04-27 23:57 -0700 |
| Message-ID | <57b5d710-e4a6-4a13-a3e7-dc262a2c8aea@googlegroups.com> |
| In reply to | #38379 |
Den tisdag 28 april 2020 kl. 08:52:52 UTC+2 skrev Jonas Thörnvall:
> I have a question not Javascript related, i understand it probably should be done in assembler or machinecode, but i am just not up to it so i look for alternatives.
>
> What programming language do have fast read write IO to file?
> It need to be able to read write continous, but not synchronus("half duplex"?)
>
> And there is no need for multiple threads read and write to same file, just a single thread at half duplex "finding position and inserting".
>
> Could python, do this in an efficient manner?
> Or should i use C?
>
> It is also a question about searching within the file at fastest speed possible.
I probably should also ask can you do incremental "inserts" to a file without need to rewrite the whole file? Is there such filehandling IO? A file allocation table seem to make inserts, but it is not a file?
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2020-04-28 14:39 +0700 |
| Message-ID | <1uzm0y92k9fpv.sz4m916a9zlq.dlg@40tude.net> |
| In reply to | #38380 |
On Mon, 27 Apr 2020 23:57:42 -0700 (PDT), Jonas Thörnvall wrote:
>>
>> What programming language do have fast read write IO to file? It need to
>> be able to read write continous, but not synchronus("half duplex"?)
>>
>> And there is no need for multiple threads read and write to same file,
>> just a single thread at half duplex "finding position and inserting".
>>
>> Could python, do this in an efficient manner? Or should i use C?
>>
>> It is also a question about searching within the file at fastest speed
>> possible.
Python can't do that by itself. It'll have to use the OS' native file
functions (i.e. API) - whether through a library or manually.
In terms of efficiency, C would be better, because the source code is
compiled to native CPU instruction. Python is interpreter based programming
language, and even though its source code can be compiled, it can only be
compiled to byte code which is basically same as Java. So, computing
resources would get wasted for interpreting the byte codes - even though it
eventually be dynamically compiled to native CPU instruction.
> I probably should also ask can you do incremental "inserts" to a file
> without need to rewrite the whole file? Is there such filehandling IO? A
> file allocation table seem to make inserts, but it is not a file?
That's within capabilities of basic file I/O functions of a system. Most
programming languages can do it as long as they can use system functions.
Whether the functions are already provided from their standard libraries, or
from third party libraries.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2020-04-28 10:55 -0700 |
| Message-ID | <ad9f4955-0957-4b07-a79a-e983b9698629@googlegroups.com> |
| In reply to | #38380 |
On Tuesday, April 28, 2020 at 1:57:48 AM UTC-5, Jonas Thörnvall wrote: > I probably should also ask can you do incremental "inserts" to a file without need to rewrite the whole file? Is there such filehandling IO? A file allocation table seem to make inserts, but it is not a file? A File Allocation Table (FAT) is not directly related to what you're trying to do. I've yet to see a File System API not provide a means to append content.
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2020-04-28 21:18 +0200 |
| Message-ID | <hgrdrpFncohU1@mid.individual.net> |
| In reply to | #38380 |
Jonas Thörnvall: [...] > I probably should also ask can you do incremental "inserts" to a file > without need to rewrite the whole file? Is there such filehandling > IO? A file allocation table seem to make inserts, but it is not a > file? Why not using a database? -- Arno Welzel https://arnowelzel.de
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2020-04-28 10:53 -0700 |
| Message-ID | <cd5f04b6-ee14-4e03-b987-f3cf4464d65e@googlegroups.com> |
| In reply to | #38379 |
On Tuesday, April 28, 2020 at 1:52:52 AM UTC-5, Jonas Thörnvall wrote:
> [...]
> What programming language do have fast read write IO to file?
> It need to be able to read write continous, but not synchronus("half duplex"?)
Most languages can write to a file, including JavaScript. Your constraint in JavaScript is that you have to use the API provided by the environment. In the Windows Scripting Host on a *.hta file for example:
```JScript
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.CreateTextFile("c:\\testfile.txt", true);
file.WriteLine("This is a test.");
file.Close();
```
In Node.js:
```JavaScript
var fs = require('fs')
fs.writeFile('/Users/joe/test.txt', "Hello World~", err => {
if (err) {
console.error(err)
return
}
//file written successfully
})
```
A browser does not let you write to a file directly though (which is probably your use-case), you instead can create the datastructure in memory and then prompt the user to download it. Alternatively you don't use a file. You can use window.localStorage:
localStorage.setItem('key', 'value');
> Could python, do this in an efficient manner?
> Or should i use C?
JavaScript is file
> It is also a question about searching within the file at fastest speed possible.
The fastest speed for searching data is to keep it in memory and organize it in a balanced tree structure such as a B-Tree or Finger Tree. I'd suggest you don't try to build one yourself.
What are you ultimately trying to do? Load and save MIDI files?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web