Solved Should I write all of my scripts in JavaScript?

  • Thread starter Deleted member 63539
  • Start date
Today, nobody knows Forth anymore, and it’s not really the typical beginners’ language.

Among my first programming experiences, if not the first, was programming a HP25 calculator.

Someone who cannot learn forth, should not touch the bootloader.
 
Learning is not a problem, maintenance is.
In order to fix a bug, you first have to spot it... :/

Among my first programming experiences, if not the first, was programming a HP25 calculator.

Someone who cannot learn forth, should not touch the bootloader.
 
Learning is not a problem, maintenance is.

I think the problem is something different: you can always expect less from users/programmers.

I note it in myself. My first text editor was a line editor, sos under TOP10, on a teletype.
As later I moved to unix (SunOS), of course I began to use ed, the standard editor
that is also a line editor. But after a while, perhaps only months, I moved to
emacs (at that time on a vt220) and that is the editor that until now I use
(nvi ocasionally). Indeed I continue to use ed in scripts, but it is in some way unthinkable to use it as normal text editor. Other people would not work without a GUI, and
a teletype or hollerith cards is for them perhaps unimagible.

For writing text I use TeX, a program from the 1970, but I know people that find it too difficult
and use word/libreoffice/etc. And TeX is indeed not simple to use, but the custom and the
lack of "better" alternatives makes me use it.

And above we read that tcl/tk is esoteric. Then no surprise that forth became more than
esoteric.

There was a time at which computer sciences students were taught LISP as first
programming languages: is LISP more appropriate than forth for beginners?
I think not even pascal is for beginners. I had the luck to begin with FORTRAN at the University.

But what about C? Programming with C means to me to continuously and carefully
count bits and bytes. Will it disappear? Is it not esoteric?
 
For writing text I use TeX, a program from the 1970

I notice that a larger divide is appearing between software but at the same time it is also an endless cycle.
People say silly things like Swift is better than C because C is 50 years old.
But in 10 years when Swift has died, the next <cool language> is better than C because C is 60 years old.
Do people not look around and reflect upon why the hell a technology has lasted so long where all the others have failed?

There isn't enough reflection or analysis going on in the computing industry anymore. Everyone just runs aimlessly after the ball like a primary school football team.

I think TeX has some fairly rough edges (especially horrible to use on deadlines ;)) and yet I almost find it appalling that nothing better has come along for 40 sodding years! Is the whole computing industry asleep? Or do they really feel that "Google Docs" is a potential competitor? Bunch of clowns haha.
 
Someone who cannot learn forth, should not touch the bootloader.
That’s not true, fortunately. Since FICL is out of the way, Forth knowledge is no longer involved in scripting the bootloader. And this is a good thing.

People shouldn’t be deterred from touching software just because some piece of technology is involved that is obsolete and difficult to handle. After all, you want to get rid of bugs, not introduce more of them.

My personal opinion: Forth stinks. :p

(PS: And I’m saying that even though – or rather: because – I am quite familiar with Forth. I’ve rewritten large parts of FreeBSD’s *.4th files in a subproject.)
 
People say silly things like Swift is better than C because C is 50 years old.
Technologies are tools, like sledgehammer. Need it? use it. Need something else? use another tool. Everything is OK? keep it at home.
But It is different story for person who has just started learning computer and programming. They need tougher discipline and to learn fundamentals. Learning C language fulfils both criteria, i.e. discipline and fundamentals.
I think TeX is a big awkward mess (especially horrible to use on deadlines ;)) and yet I almost find it appalling that nothing better has come along for 40 sodding years! Is the whole computing industry asleep? Or do they really feel that "Google Docs" is a potential competitor? Bunch of clowns haha.
Google Docs is OK for compiling some classes of documents, for example reddit posts.
 
People shouldn’t be deterred from touching software just because some piece of technology is involved that is obsolete and difficult to handle.

A computer scientist told me seriously, not joking, that also mathematical theorems get obsolete.
 
Since this thread is ruined already, Lua is a great fit for replacing Forth, because Lua is designed to basically expose C functions to scriptability. Lua is used in all sorts of places (so it isn't a complete waste of time to invest in) while Forth is... not.

That being said, don't try and write what are effectively shell scripts in Lua (for now).
 
I know Forth was very portable and small which is why I thought it was quite well suited for a bootloader.
Lua is not quite as portable (still pretty good though) and not quite as small.

Is the bootloader really such a complex and large project that it needs such a full fledged scripting language?
 
Yes, awk(1) is somehow a mix of the spirits of the declarative & imperative programming paradigma.
Your script is errorneous: you have to look for UID 0, not only the name root. Usually we have only the toor user (sh(1) or bash(1) instead of csh(1)), but anyone is free to add any other name with UID 0.
I did say it was a contrived example. I chose to match username because UID 0 would've also matched the toor user who has no shell in any of my Freebsd systems.

I wanted to show how regex matching works in patterns, and a text example is more informative. Also, I wanted to handle the case where there was no field number 7 (i.e., no shell).
 
And it should be emphasized that all of those 7 items are optional. For example, if you don’ need that pattern stuff, you can write an awk script that consists only of one BEGIN clause (with all of the code inside), and nothing else.
To go even further, no pattern is needed, {print $0} is a valid though trivial awk(1) program.
 
I think Lua's been very popular in the game development industry for about a decade, maybe because of it historically had an extremely open license

The idea of "exposing C functions to scriptability" comes from tcl and the widget toolkit tk
used in many scripting languages (python among them) is designed for tcl and part of the
same project. Also tcl has an extremely open license: the BSD license. And there is a lot
of software written in tcl and it is very easy to write other, but for some strange reason
people forgot tcl.

And now there is a modular, smaller footprint version of tcl under FreeBSD license:


But that is not a reason for putting tcl everywhere.
 
You can always read about Lua capabilities, benefit, versus, etc. on the web. I have an analogy. Lua reminds me of SQLite. Lua to scripting, its embedded nature and its interface/API to C (and other languages) is similar to, SQLite to RDBMS/embedded and its interface/API to C. Keep in mind that I don't claim that SQLite and Lua are same creature. If you know both, you'll find many similarities.
[EDIT] Reading these documentation might help:
 
Yes, vigole, but this extensibility with a C Api was the original idea of tcl and tk. Is not an
invention of lua. And sqlite began as an extension of tcl. No wonder that you find there
similar ideas.

The interpreters tclsh/wish are small programs that use these well documented tcl and tk libraries:


Perhaps the advantage of lua is, that it has a smaller footprint. But as I noted, there are other
implementations of tcl with small footprint. Also fossil has its own:

 
  • Like
Reactions: a6h
I know Forth was very portable and small which is why I thought it was quite well suited for a bootloader.
Lua is not quite as portable (still pretty good though) and not quite as small.
Yes, Lua is a little larger than FICL, but not by an order of magnitude.
Code:
> ll /boot/loader_???
-r-xr-xr-x  1 root  wheel  245·760 Jun 14 17:08 /boot/loader_4th
-r-xr-xr-x  2 root  wheel  290·816 Jun 14 17:08 /boot/loader_lua
And the benefits definitely outweigh the growth in size. Again: FICL was end-of-life for a long time already, did not have a maintainer and was suffering from bit rot. It had to be replaced. There was simply no way to keep it.
Is the bootloader really such a complex and large project that it needs such a full fledged scripting language?
Whether it “needs” it is debatable. You can do without, but that makes certain things harder, less flexible and more error-prone.

Having a scripting language makes it much easier (and more secure) to perform certain tasks. The whole user front-end (menus etc.) is written in Lua. For example, this is important for OEMs who embed FreeBSD in their products because they usually need to make changes in that area.

It’s also much easier to make the respective changes if FreeBSD gets a new logo. ;)
 
They need tougher discipline and to learn fundamentals.
I find most young people who want to learn programming and computer usage are always looking for an easier way to get around having to do that. Those are the people who want to not learn C, math, science and are always on reddit or Stack Overflow looking for a framework or library that will do the work for them rather than understanding how things work.
 
always on reddit or Stack Overflow looking for a framework or library that will do the work for them

I noticed this with my students. I don't think they particularly mean to be lazy either. I put it down to a few things:

1) They come from Windows where everything is such a faff to do unless some software does it for you. I.e the OS is basically crippled unless you specifically download a tool to do something

2) They are under the impression that they are hopeless and that they couldn't possibly manage anything by themselves. I certainly blame poor UK A-level / GCSE syllabus for this (and some university courses).

3) A bad habit they pick up around work colleagues and "modern" management who think speed makes them great, sod the quality of work. This unfortunately is worse in the web-dev sphere giving rise to the most frameworks and a bad name. I notice that students on placement to these kinds of companies pick up this habit much worse! Arguably the web development world should be one most focused with quality and security!
 
I find most young people who want to learn programming and computer usage are always looking for an easier way to get around having to do that. Those are the people who want to not learn C, math, science and are always on reddit or Stack Overflow looking for a framework or library that will do the work for them rather than understanding how things work.
Aren't these the very ones who end up coding everything client-side in javascript.? They just copy/paste and hope it works... :'‑(

And encouraged by the mess created by Google et al.
 
Back
Top