Live data from Hacker News

Lite: A lightweight text editor written in Lua

github.com

21–30 of 81 posts

Re: Lite: A lightweight text editor written in Lua

#22
post #5

So it uses SDL2 as a rendering engine. Does it roll its own widget library?

No; rxi wrote a rendering cache infront of the renderer. It doesn't require a widget library for this reason; it's able to efficiently implement an immediate renderer. Simplifies the codebase a lot.

Re: Lite: A lightweight text editor written in Lua

#23
post #4

Lite (and lite-xl) is an amazing little editor. I especially love how fast the program opens. There’s just a few small things that bother me enough to keep me from using it, but I remain impressed by the code and how lightweight it is.

Hey; I'm part of the dev community over at lite-xl; what're your top asks? I can see if we can throw it into the feature queue (though the queue is already pretty long).

Re: Lite: A lightweight text editor written in Lua

#24

Earlier quoted context omitted.

> There are many such projects, like Atom.io, whose support ends this year. I can't imagine this project will continue much further, even if I hope so. The only real open source project that is up today is Visual Studio Code, but that will continue to be maintained, I hope. What do you mean real open source project? I mean Linux is not going anywhere soon I'd say, or blender. Or are you talking about editors? There i…

I mean open source IDE's, real full featured developer environments for writing code. I don't talk about Open Source projects in general, but about competition for VS Code or Eclipse. There is something like Sublime Text, but it's not really open source and free. Edit: With Vim and stuff I get your point, but I would say it's not really comparable to an UI-based IDE, it is command line stuff. Even if many people pref…

https://eclipseide.org/

Re: Lite: A lightweight text editor written in Lua

#25

This is neat. I remember learning some Lua in order to write some custom Redis functions, and I was blown away by how handy of a language it can be. The indexing definitely tricked me a few times though.

Yeah; the indexing is weird when you're not used to it; but honestly I find starting arrays at 1 is actually incredibly useful for business logic. It's terrible for math, but it allows you to use things like truthiness really effectively for compound statements that return indices and stuff.

Like, for example, `string.find` returns the index where something's found. You can just do `if str:find("a")` if you want to test to see whether a string contains "a", whereas in most other languages that test for location you're required to check that the result isn't equal to `string::npos`, `null` (if your langauge supports that), `-1`, or some other value that's not 0. Lua, you can assume that it's truthy if it's found, because 1 is the start of the string, not 0.

Took me a while to get used to, but I really like the idiom now for things that just high-level string stuff, and glue code.

Re: Lite: A lightweight text editor written in Lua

#26
post #25

This is neat. I remember learning some Lua in order to write some custom Redis functions, and I was blown away by how handy of a language it can be. The indexing definitely tricked me a few times though.

Yeah; the indexing is weird when you're not used to it; but honestly I find starting arrays at 1 is actually incredibly useful for business logic. It's terrible for math, but it allows you to use things like truthiness really effectively for compound statements that return indices and stuff. Like, for example, `string.find` returns the index where something's found. You can just do `if str:find("a")` if you want to t…

I don't mean to screw up the whole vibe of your comment, but...

    if 0 then
        print('0 is true')
    else
        print('0 is false')
    end
prints "0 is true". The reason why "you can just do `if str:find('a')`" is because it returns nil.

string.find never returns 0.

Re: Lite: A lightweight text editor written in Lua

#27
post #25

Earlier quoted context omitted.

Yeah; the indexing is weird when you're not used to it; but honestly I find starting arrays at 1 is actually incredibly useful for business logic. It's terrible for math, but it allows you to use things like truthiness really effectively for compound statements that return indices and stuff. Like, for example, `string.find` returns the index where something's found. You can just do `if str:find("a")` if you want to t…

I don't mean to screw up the whole vibe of your comment, but... if 0 then print('0 is true') else print('0 is false') end prints "0 is true". The reason why "you can just do `if str:find('a')`" is because it returns nil. string.find never returns 0.

That's what I mean. It never returns 0, so is thus always truthy if it finds something.

If you do `if (str.indexOf("a"))` in javascript; you'll miss out on the case where the string starts with "a", because the index returned 0, which is falsy.

EDIT: Oh, sorry, I see what you mean. You're right, my bad.

EDIT2: I guess, let me rephrase. 0 is rarely returned for things, so the falsiness of it doesn't usually enter into the equation. So you can do things like that, regardless of the truthiness of 0, because it's not used, whereas in other langauges, you usually have to check, unless they have 0 as truthy as well. (though I guess this isn't much of an argument in favour of 1-indexes)

Re: Lite: A lightweight text editor written in Lua

#28
post #24

Earlier quoted context omitted.

I mean open source IDE's, real full featured developer environments for writing code. I don't talk about Open Source projects in general, but about competition for VS Code or Eclipse. There is something like Sublime Text, but it's not really open source and free. Edit: With Vim and stuff I get your point, but I would say it's not really comparable to an UI-based IDE, it is command line stuff. Even if many people pref…

https://eclipseide.org/

Yes, I mentioned that in my edit. A shame that I forgot it in the first place :P But after VS Code and Eclipse there isn't much else...

Re: Lite: A lightweight text editor written in Lua

#30

I've looked at this codebase and that of the XL version. Can a neone explain why there's C code there if it's meant to be lua? Genuine novice question. Thanks.

The other replies are correct, but there is a bit more to it.

Lua is a very small language with a tiny standard library. To extend it you write modules in C (or another language with bindings). This allows connecting the Lua code to various libraries. A notable example in lite is SDL. Without the C code in this repo the Lua code wouldn’t be able to use SDL for drawing or inputs

Post reply on HN