Hacker Newsnew | past | comments | ask | show | jobs | submit | marklgr's commentslogin

Could you elaborate?


A for loop in a shell script may sometimes look like this:

`for ((i = 0 ; i < max ; i++ )); do echo "$i"; done`

Here this is essentially a "while" loop, meaning it will keep executing the commands as long as we don't reach `exit 1`.

(; flock -n 9 || exit 1; # ... commands executed under lock ...; )


It doesn't seem to work?

  [~] 0 $ ( flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock
  in loop
  done working
  [~] 0 $ (; flock -n 9 || exit 1; echo in loop ; sleep 3 ; echo done working ; ) 9>~/tmp/mylock
  -bash: syntax error near unexpected token `;'
  [~] 2 $

(This is bash)


I've been using the Boldvoice app (no affiliation), it's not perfect but pretty good; my spoken English has definitely improved in a few months. I would recommend it.


Can't be natural selection, can it? Sheer luck?


If someone finds a way, I'm in.


FWIW, if you just like the filename on the left, you still can save forks with:

`<quux grep xkcd`


It's like trying to save money on matches.


> But we should look at what Lua did for Neovim. There has been an explosion of development effort now that Neovim finally added a reasonable programming interface.

It is very much debatable whether Lua is the "reasonable programming interface" causing the activity in Neovim. Vimscript has many flaws, one of them being that it doesn't look like other programming languages, but it does its specialized job pretty well. It is slow, but efforts are made in that area. Lua is well designed but it certainly has its shortcomings too, and many argue (me included) that programming in Lua is not that pleasant. The Lua bindings have been available in Vim for quite some time, but they never were popular, for some reasons.

Anyway, it is not directly related to your point, but I think that example is not that compelling.


Lua is a really good lure. You add it to a project and a bunch of people go "oh neat, I've heard a lot of good things about lua, I'll do this idea I've had in lua."

And then the realities of working in lua accrete over months, but then they're in too deep. What are they gonna do, learn elisp? Admit defeat and switch back to VS code?


> What are they gonna do

Personally, I'm using Haxe with its Lua backend. While wrapping Lua APIs is a pain, and some dynamic patterns are hard to represent directly, Haxe provides a lot of the things that Lua lacks: a gradual static type system, more familiar JS-based syntax, syntactic sugar for lambdas, sane handling of `this` in methods, control over inlining, immutable variables, generics, null safety, powerful hygienic macros, somewhat usable standard library, extension functions (Kotlin/Scala3 like), partial function application, hash and array comprehensions, functional operators on collections, limited operator overloading via abstracts, built-in LSP server, and a lot more.

I do this in the context of scripting my window manager, and plan to try this with Nginx/OpenRESTY. I feel like pairing LuaJIT runtime with Haxe compilation creates incredibly powerful combination. Lua provides coroutines, tail call elimination including corecursive functions, lightweight and fast JITed VM, a package manager (luarocks), bindings to important C libraries, FFI, reflection (everything is a table anyway), and more. The integration between Haxe and Lua is not yet seamless, and Lua compiler backend is one of the least developed, but even in this state I'm very happy with the combination of compile-time and run-time features I get.


Ha interesting, I didn't really expect a serious answer but very cool. I looked into haxe a while back when I was gearing up for a significantly complex project targeting lua 5.1.

I ended not using it mostly because of unfamiliarity and it felt like it would add a fair bit of complexity. Didn't want to pick up a whole new ecosystem for that project.

I ended up using fennel, which solves most of my practical problems with lua without really making anything harder. Doesn't help with the package ecosystem or build process but I ended up just taking that compromise.

Don't regret it, still use fennel anywhere I'm forced to use lua, including hammerspoon and mud client scripting. I think if I was going to work heavily in lua long-term I'd go back and invest in haxe for it.


Reading the docs and searching into it on a regular basis is the single best advice I could give to Vim users wanting to improve. The odd cheatsheet, the post with a few tricks and cool plugins, all those can be well and good, but nothing beats sitting down and reading the docs. I've been use Vim daily for 10+ years, and I still check help files very regularly. Knowing _how_ to search efficiently is also a skill worth acquiring.

Incidentally, the same advice apply to Bash: just read the man page, and search into it each time it is needed. It is just worth it.


> "If you have to write more than 10 lines, then use a real language"

I swear, there should be a HN rule against those. It pollutes every single Shell discussions, bringing nothing to them and making it hard for others do discuss the real topic.


There are three numbers in this industry: 0, 1 and infinity. Any other number - especially when stated as a rule, limitation, or law - is highly suspect.


Are you one of those people who take everything literally, so any and all jokes fly far over their heads?

This rule of ten lines or less is clearly meant as an illustrative guideline. Obviously if you have a shell script that has 11 lines, but does what it has to do reliably, nobody will be bothered.

The idea that the rule is trying to convey is "don't write long, complex programs in shell". Arguing about exact numbers or wording here is detracting from the topic at hand.


0, 1, 3 and infinity


Which works not just to preserve the previous statement from internal inconsistency, but also in regards to the incredibly useful Rule of Three (https://en.m.wikipedia.org/wiki/Rule_of_three_(computer_prog...).


> Which works not just to preserve the previous statement from internal inconsistency

It doesn't. You now have 4 numbers.


0, 1, 3, 4 and infinity - there's four numbers in this industry.

Five There's five numbers in this industry 0, 1, 3, 4, 5 and infinity

Wait, I'll come in again


0, 1, 7, and indeterminate, IME.

The 7 being for design. If there are more than 7 boxes on the whiteboard, try again.


ah, log base 2 of 7 is 127 bits (aka 8, y 1).

Unicode character can have more than 7 font boxes associated with one character box and still be a valid determinate character form.


thought the industry was broken down in 8 bit increments (0, 8, 16, 32, 64, 128, etc)

log base 2 of 4 is only 16bits


Good point. I'm not sure why I thought what I'd written above worked... shrug


Think use a real line discipline like n 8 1 would make more semantic sense than 'use a real lanaguage'.

Unless, the language is APL, in which case, 10 lines is an operating system.


The majority of those comments have significantly more thought put into them (and adhere more closely to the HN guidelines) than this comment does.


Is there a link to HN line discipline criteria? (beyond asci ranges 0 through 31)


It's a case of knowing the wooledge website (and working with shellcheck), or not. Picking snippets on stackoverflow will probably do more harm than good, tbh.


Did you hang out at Maubert Electronics? I also recall a few RTC servers, blast from the past!


Blast from the past for sure, OP was not but I was in Paris in the early 90s, and HP48 hacking was huge. I remember attending class, ignoring the teacher, and just patiently leafing through long print outs of HP48 disassembly, or typing in assembler programs on the calculator itself.

The software on this thing was pretty amazing, but surprisingly hacky in some ways. The RPL language had a system of embeddable objects in memory, but when the interpreter had to skip over an object (i.e all the time), there was no field marking its length, so it had to actually recurse through all the sub-objects to find the end.

IIRC there was the a hack where some memory locations could contain a direct pointer or a pointer to a pointer, and it would work either way because the same bits could be interpreted as a pointer or directly executed... or something of that sort.


RPL tokens were addresses of machine code routines (stored in 20 bits)


I still remember 3223 :)


I was not living in Paris at the time, I've been there a few times, but yeah, the French HP48 scene was super active and exciting.


The French HP48 phenomenon was always interesting to me. How did that happen? I'm in the US and we had a French high school student visit over the summer. Always talking about the HP48SX, though he didn't bring it with him. But when I needed to get a graphing calculator I ended up buying an HP48GX instead of the recommended TI-83 (I ended up getting one of those as well). I used the 48GX throughout middle school and high school w/Meta kernel, Erable - the developers of which all French, ended up working for HP ACO. Used a 50G later on. It was always interesting to me how the development powerhouse for the HP48 series was all French, but never really understood how that happened. Was there some schooling mandate similar to TI in the US?


It was a hacking scene with a few talented guys with strong enough personalities to organize meetups and write fanzines articles.

Also, the model was popular in preparatory schools because of the expansion slots, it was possible to extend the memory by a huge margin.

This memory was useful to store, well everything you could, and at the time those calcs were not forbidden during exams.

Some people (including me) even wrote text editors and viewers with support to display a mix of text and picture for schematics, physics or chemical diagrams...

The US scene was also extremely helpful, with people such as JK Horn or Eric Rechlin.


Most schools recommended TI instead of HP (at least in the late 90s). The few people I knew who also had an HP48 or HP49 tended to be enthusiasts and all ended up studying CS at an Engineering school.


I have the strong feeling that hp28/hp48 have a deep impact in IT industry given the number of smart and passionated peoples who self taught themselves low level programming before 18yo with them.

Im 43 it guy and started playing with hp at 12, my own first « computer » with countless hours: playing, coding, debugging, reading txt files. Naturally when I bought my first intel computer at 19yo I installed freebsd, to later go to openbsd and Linux.

And the first thing I do on my android phone is to install hp48 emulator.


Most of the people who were active in the HP48 scene turned out to be good to great coders with a good knack for low-level optimization.

You may have heard of LZ4 or ZStd, the author is a French guy (currently employed by Facebook) who started hacking compressors on his HP48, this is how I met him a long time ago.


3614 RTEL2 - with a custom serial cable to connect the HP48 to the Minitel !


Blast from the past! Amazing discussion.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: