Live data from Hacker News

Lessons learned from implementing a text editor related to front-end development

lpan.io

51–60 of 191 posts

Re: Lessons learned from implementing a text editor related to front-end development

#51

not C, but probably very C useful http://scienceblogs.com/goodmath/2009/01/26/ropes-twining-to...

Also not C, but closer: https://docs.rs/xi-rope/0.2.0/xi_rope/

This is a rope implementation in Rust with lots of features useful for text editors.

Re: Lessons learned from implementing a text editor related to front-end development

#53
post #31

I'd like to post a purely positive, encouraging comment here :-) Thanks for the article, and good job implementing an entire editor from scratch in C! That's impressive. Also, as a very accomplished programmer who happens not to have done much recent UI programming, who has read quite a bit about React/Redux/Rewhatever, Elm, The Haskell School of Expression, etc., I find articles like this extremely helpful: you took…

Thank you, for this! I could not say it better/nicer. I was getting upset with the overwhelming negativity here. Monday morning syndrome?

Re: Lessons learned from implementing a text editor related to front-end development

#54

It is not surprising that C gets that much of a bad reputation when devoloper show such poor capacity at managing errors; malloc(3) return values are never checked and everything is expected to always succeed, throughout the source tree.

The reason for not checking malloc is that it's most likely to kill your program instead of returning a failed allocation

Why would a system do that? Either it overcommits, in which case the malloc won't fail (programs get killed only when they try to actually use the memory) or it doesn't, in which case there's no reason to kill it.

Re: Lessons learned from implementing a text editor related to front-end development

#55

Earlier quoted context omitted.

All this screams to me "education". The self taught diy thing is great, but on mass scale it's inefficient. If all these devs (I could include myself) could spend 6 months doing all this together sharing the common patterns and then go out fixing other problems ? Also SICP/HtDP

One, who just has a free 6 months? Two, do you honestly think you can fit a comprehensive CS education that would satisfy people like you in six months?

1. Most westerners born outside the USA. And in the USA anyone willing to take out a loan.

2. The core requirements for a cs major at a typical university (read: not CMU,MIT,Stanford,Berkeley) and especially at a non flagship is basically 4 or 5 courses, which you can for sure cram into 6 months if that's all you're studying.

Personally, I'd rather work with people who learn some part of that on their own (or even not at all) but have a stellar education in reading, writing, and math. The former are often provided by good high schools. The latter not so much. At least in the states.

But if all you want is just the core fragment of just the cs, six intense months are enough.

Re: Lessons learned from implementing a text editor related to front-end development

#56
post #53
post #31

I'd like to post a purely positive, encouraging comment here :-) Thanks for the article, and good job implementing an entire editor from scratch in C! That's impressive. Also, as a very accomplished programmer who happens not to have done much recent UI programming, who has read quite a bit about React/Redux/Rewhatever, Elm, The Haskell School of Expression, etc., I find articles like this extremely helpful: you took…

Thank you, for this! I could not say it better/nicer. I was getting upset with the overwhelming negativity here. Monday morning syndrome?

Unfortunately HN can be unnecessarily negative sometimes. Thanks for the interesting article!

Re: Lessons learned from implementing a text editor related to front-end development

#57
It's worrying how sometimes the most basic programming concepts can appear revolutionary to web developers. So much so, they've recently stumbled across the concept of a read input-update-render loop, and are now trying, with frameworks like React, to contort the DOM tree, just to get back to how UI was programmed since decades.

There's a fairly old concept called "immediate mode UI", which even gets rid of the tree structure, and keeps the whole state on the user side, giving you full control over when elements are updated and where they are placed. These days it's used mostly in video games, since they already rely on a 60 FPS loop, and the UI complexity tends to be low.

If not for the necessity to use standard platform form elements due to their various quirks and interactions with the system, I'd be doing UI programming only in immediate mode with custom controls, simply because how convenient, and simple it is.

Re: Lessons learned from implementing a text editor related to front-end development

#58
post #24

It is not surprising that C gets that much of a bad reputation when devoloper show such poor capacity at managing errors; malloc(3) return values are never checked and everything is expected to always succeed, throughout the source tree.

On a modern Linux kernel in its default configuration this is AFAIK actually the case? The kernel overcommits memory. http://www.win.tue.nl/~aeb/linux/lk/lk-9.html#ss9.6

Do other *nix systems behave differently regarding overcommit of memory and malloc() really only erroring out when virtual memory is exhausted (which basically never happens)?

Re: Lessons learned from implementing a text editor related to front-end development

#59
Very interesting work! It seems that educational text editors are becoming a trend after Antirez published his :-)

Excuse me the shameless plug, I'd like to show mine too: https://github.com/arximboldi/ewig

It is written in C++, but using a style that is unlike what most C++ developers use: it is composed mostly of pure functions. The architecture is very much like that of Elm programs, and there is even a `store` class like in Redux.

Like the project from OP, it is about 2K lines of code. But it also supports asynchronous loading/saving, copy-paste (you can copy-paste a 1GB file instantly), very robust undo, dirty markers, UTF-8 (not perfect), etc.

The magic? Immutable vectors based on RRB-Trees. This is like the vectors in Clojure/Scala, but also supports log(n) slicing, concatenations, insertions---these operations are fundamental for a text editor, and I'd say, to most interactive software supporting big data models [1].

The code has been written in a style as simple as I could. I'd like to think that even non-C++ developers might be able to understand it. It might be specially interesting for web developers invested in Clojure, Elm or Redux and the single-atom architecture.

Probably one day I should go ahead and just write a blog post about it or a tutorial or something. But so far I don't have a blog I am not really a social media person. The code is still moving also...

PS. And thanks a lot to @kostspielig her help writing and reviewieng the code! [1] The data-structure can be found here: https://github.com/arximboldi/immer

Re: Lessons learned from implementing a text editor related to front-end development

#60
post #53
post #31

I'd like to post a purely positive, encouraging comment here :-) Thanks for the article, and good job implementing an entire editor from scratch in C! That's impressive. Also, as a very accomplished programmer who happens not to have done much recent UI programming, who has read quite a bit about React/Redux/Rewhatever, Elm, The Haskell School of Expression, etc., I find articles like this extremely helpful: you took…

Thank you, for this! I could not say it better/nicer. I was getting upset with the overwhelming negativity here. Monday morning syndrome?

It's because the challenge he set himself isn't hard and he didn't do a particularly good job of it either (other comments have covered that so I wont reiterate it) yet he is soapboxing his experiences as if the topic isn't entry-level stuff. And I mean "entry-level" quite literally as you learn about event-driven programming in high school or equivalent IT classes. This isn't something you need a CS degree to learn.

I mean kudos to the guy for trying something new but honestly I'd expect anyone working as a developer in IT to have learned this much before calling themselves a professional. And that includes Javascript devs since so much of frontend development is event-driven anyway.

Personally I get a little fed up by just how _bad_ many frontend developers seem to be these days. I'm not tarring everyone with the same brush as I'm known some really amazing frontend devs too (though they ususally consider themselves full stack). But I've lost count of the number of Javascript developers who I've had to explain HTTP status codes and the difference between GET and POST. It feels like frontend development is a place where people go if they like the idea of coding but can't be bothered to learn how to actually programme nor any of the principles they're building their code on top of. Thankfully the topic author bucks that trend a little but even in his case the lessons he is learning are painfully basic.

By the way it's a bank holiday (long weekend) in the UK so no Mondays blues from me. :D

Post reply on HN