Lurker News
I think I've broken my own record with this one ~2500 lines of incoherent JavaScript/C#. Works though.

Comments (578) 119 threads

Earlier comments
rollulus7 replies#
At my first gig I teamed up with a guy responsible for a gigantic monolith written in Lua. Originally, the project started as a little script running in Nginx. Over the course of several years, it organically grew to epic proportions, by consuming and replacing every piece of software that it interfaced with - including Nginx.

There were two ingredients in the recipe for disaster. The first is that Lua comes "batteries excluded": the standard library is minimalist and the community and set of available packages out there is small. That's typically not an issue, as long as one uses Lua in the intended way: small scripts that extend existing programs with custom user logic (e.g. Nginx, Vim, World of Warcraft). The second is that Lua is a dynamic language: it's dynamically typed, and practically everything can be overridden, monkey patched and hacked, down to the fundamental iterators that allow you to traverse data structures.
This was the playground for the guy to create his own reality.
Lacking a serious standard library, he crafted his own. Where a normal world e.g. file rename function would either do the job or return a error to the caller, he chose a different approach. Functions were autonomous highly intelligent pieces of code that tried to resolve every possible problem, entangled with external logic, so grokking the behaviour of the most fundamental things was challenging - let alone understanding fragments of code composed of library calls.
Lacking a OO model in Lua, he built his own. I can spend a lot of time describing with what was wrong with it, but it suffices to say that each object had SIX different 'self' or 'this' pointers, each with slightly different semantics. And highly entangled with external unrelated logic of course.
I'll save the stories about the scheduler and time series database he built for another time.

abledon#
“This was the playground for the guy to create his own reality.”

Queue the Neil Gaiman sandman styled comic about his dark adventure

mercer#
I'm a masochist and would very much like to hear about the scheduler and time series database!
packetpirate#
We've got a Robert Heinlein fan here...
humanrebar3 replies#
I've seen personal reality building happen in Lua several times already. It's very seductive to intelligent solo artists who are given a lot of freedom.

To be fair, I've also seen it happen in C, C++, and JavaScript.

pageandrew#
Ruby as well. I went down that path once. I learned my lesson.
rollulus#
That's spot on, the guy is indeed one of the most intelligent, knowledgeable and dedicated persons I've ever met. Actually a really good guy.
julianz#
"personal reality building" is the greatest quote in this whole thread, it's perfect. Will be using.
james_s_tayler#
This is gold.

Part 2 please???

italomaia_b#
Well, OO libraries for lua were not popular nor standardized until not long ago, so, the default suggestion for it was actually to create your own OO lib, which many projectes ended up doing (mostly in the same way), which led to some trouble.

For replacing nginx with lua, that is curious. Openresty is not being used? No web framework? (lot of lua dead web frameworks in the road, by the way)
Also, "creating your own reality" is usually a bad thing in any language. That usually happens when you're developing something alone, for long and didn't give maintenance to other peoples code much in the past.
In another related point: lua is NOT supposed to be used as glue/extension code. It was designed so that it would be easy to do so. It is that "you can" more than "you should".
Lua doesn't come with batteries included, by design and doesn't have a plethora of libraries available or (coff coff) easy to pick from, but, they do exist and they do solve most problems. Nonethless, truth be told, most of the good api for Lua one sees nowadays, was not available 1 or 2 years ago or not mature enough.
To conclude, lack of type hinting in Lua or optional static typing can create problems for bigger problems if good design, testing and documentation is not enforced from day 1. Most scripting languages suffer from this. You guys could try "ravi" to get this (almost) for free.

italomaia_b#
Also, give us part 2 =D
hprotagonist2 replies#
Behold, academia.

The only maintainers of this code, ever, have been grad students and postdocs. I estimate there have been about 12-15 generations worth. This code has supported hundreds of publications in its lifespan.
A codebase that began life in 1987, in C. First ported to matlab in 1999. First source control was added (as SVN) in 2015. Between 2015 and 2018, there were 6 commits total, yet 3 people graduated out of the lab from it. Probably 100,000 loc total, of which I estimate maybe a third is ever used. 1400-line matlab functions are normal-ish. I've found loops nested 11 levels deep.
It's a series of psychophysical experiments. Each experiment exists in at least 4 different versions side by side in source, each named slightly different, often by incorrect datestamp of last modification. Version control across machines is not well maintained, so you have to diff everything before you can copy or move files lest you accidentally blow something away completely.
Oh, and it's mexed and wrapped for use on a mac on exactly one snow leopard machine, hardware from 2007.
edit: I think this counts as a job, not a student experience, because I am not a student. I just have to clean this mess up once in a while.

mlboss1 reply#
I think it is a problem in general with code for experiments. You just need to change a tiny bit for new experiment and you don’t want to ruin earlier experiment.
humbledrone1 reply#
There's a very simple solution: guard your tiny bit of code with e.g. a command line flag that defaults to "off", and commit that.

It's a little more work sometimes, especially when your experiment changes things structurally, but it pays off over and over.

alexbecker2 replies#
Isn't this what git branches are for?

Continue this thread — 2 replies

fao_#
Yeah. At this point I think teaching source control and abstraction should be part of the "the scientific method" part of the course
madmax1087 replies#
A customer-facing dashboard. Yes, a dashboard. How bad can a dashboard be bad you ask? Well, for one, the dashboard had tabs, and each tab was a separate webapp hosted on a separate server. And each team was responsible for developing and maintaining the webapp that their team was incharge of (i.e the User team in charge of Users webapp, Feature1 team incharge of Feature1 webapp).

Now add on the fact that different teams had varying levels of frontend competence. This led to some webapps being in (badly written) React, some in Angular, some in JQuery and one in Angular2 as well. Some were java API backed, some were NodeJS backed and one used Ruby in the backend. Oh yeah, and each had different datastores as well.
Now alongside this, there's no central auth framework, so each webapp had their own way of how to determine user auth (there was a shared cookie thankfully on the *.company.com domain), so there were 6-7 possible login and logout pages as well.
When the company had a brand redesign and needed all customer facing stuff to re-align with new design, we had to literally re-design 6 dashboards which have used different paradigms and different tech stacks.
To this date, the dashboard still exists and is used by customers (Main dashboard for a company valued at $500M+) and the most common issues are issues related to Auth (eg. random logouts when switching tabs), data inconsistency (They have crons which update data from one DB to another, but it's not immediate) and an inconsistent design and UI behaviour (since JS is also different for each app) which pisses off many users.
Till date, I'm not sure who signed off on this pointless dashboard design.

verelo#
I've run into exactly this issue at a past job, multiple webapps run by different teams that were "tabs", with a central auth system. I turned up, saw this and couldn't believe my eyes. Basically because teams couldn't agree on working together, they made this horrid attempt of a service based architecture and the result was chaos. I know monoliths are not popular, but they have their place in early stage companies where moving fast v's having a trendy design is critical. Company went out of business a few years later...
ible#
Talk about shipping the org chart.
ahi#
Microservices!
CoolGuySteve1 reply#
Sounds eerily familiar to something we had at the investment bank I worked at. I'm guessing this is in finance and these apps are from different departments/desks?
lapnitnelav#
Teams not collaborating is the giveaway.
lowry#
Aha! This is the Spotify model!
quickthrower2#
Sounds like many resumes were polished at that company.
awestroke#
Sounds like how they do it at Spotify
gnulinux18 replies#
We have absolutely no idea how to write code. I always wonder if it's like this for other branches of engineering too? I wonder if engineers who designed my elevator or airplane had "ok it's very surprising that it's working, let's not touch this" moments. Or chemical engineers synthesize medicines in way nobody but a rockstar guru understands but everyone changes all the time. I wonder if my cellphone is made by machines designed in early 1990s because nobody was able to figure out what that one cog is doing.

Software is a mess. I've seen some freakishly smart people capable of solving very hard problems writing code that literally changes the world at this very moment. But the code itself is, well, a castle of shit. Why? Is it because our tools (programming languages, compilers etc) are still stone age technology? Is it because software is inherently a harder problem than say machines or chemical processes for the human brain? Is it because software engineers are less educated than other engineers? .....?

abledon#
Your 2nd to last one is right I think. Other forms of engineering are constrained by physical world rules. In software we have to recreate reality and redefine and model how the real world system works. Mech eng/ chem eng etc don’t have to recreate reality , physics just works and will always work .
b_t_s#
I think it's because software is inherently easier and less critical...castles of shit actually work. Software is fairly unique in that level of quality and reliability needed to have significant economic benefit is very low, and the consequences of system failure are rarely severe. That's not the case in most branches of engineering. The complexity levels are also off the charts, in large part because economic value is so loosely coupled with quality. In many cases more turds are more profitable.
52-6F-621 reply#
>I wonder if engineers who designed my elevator or airplane had "ok it's very surprising that it's working, let's not touch this" moments.

I honestly sometimes do wonder. Judging by the elevators in my building some things even barely work at times. They go down often and require parts replacements that take weeks to arrive. They're barely 3 years old.

krallja1 reply#
> They go down often

Isn’t that one of the two main features of the product?

gnulinux1 reply#
"to go down" means "to be in a non-functional state" as in "Facebook went down". Compare to "to go up" like "servers are up" i.e. servers are functioning.

Continue this thread — 1 reply

enjoiful2 replies#
The difference is, an elevator is a precisely defined problem and never needs to have its functionality improved and changed.

In fact, you could build the exact elevator almost identically. Software is never like that — it’s dynamic and constantly changing throughout the life cycle of the software.

Invictus01 reply#
> an elevator is a precisely defined problem

Ha! As a mechanical engineer, no, nothing in reality is ever precisely defined. Consider that every single part in the elevator has a tolerance: none of the parts are exactly the same in every elevator. Did you account for thermal expansion? What about wear? Fatigue?
> Software is never like that — it’s dynamic and constantly changing throughout the life cycle of the software.
But elevators need to be shipped right the first time and can't make mistakes; with software, it almost never works perfectly no matter how much time passes.

gnulinux6 replies#
> with software, it almost never works perfectly no matter how much time passes.

There is a person inside me -- whenever this is said -- that wants to shout "No! You can prove correctness of your program!". But this complicates the issue even more, since afaik no elevator's correctness is proven but it just works. Mechanical stuff somehow just magically work without proof whereas it's still debatable if proven software works (did we prove the software that proved it?). I don't know what's the difference. Maybe elevator has a well-defined structure, it goes up and down, opens the door etc, even though implementation can change (as you explained). But maybe software isn't like that. Idk.

Continue this thread — 6 replies

buitreVirtual#
Indeed. Writing software is akin to drawing the design of the elevator, not building an individual copy of the elevator. Each elevator is equivalent to one instance of the software deployed to run in one place. The same design/code is used to build/create multiple instances. So when we write new software to solve a new problem, we are designing something new and unique - not another blueprint for the same elevator.
pier25#
The best code I've written is when rewriting some code from scratch having a clear picture of the solution, or when I solve the same problem a couple of times.

Solving complex stuff takes a lot of effort, and usually most companies do not have the resources or the motivation to go back and rewrite a product.

sonnyblarney1 reply#
Brilliance is not indication of an ability to write clean code.

In my experience, code needs to be re-factored 3 times before it starts to look coherent and clean.
But 99% of projects can't justify that kind of expense.
But good code is very feasible, just takes time.

james_s_tayler1 reply#
I'll expand this further by saying yes to all of the above with the addition that to get it perfect in my experience requires about 7 iterations.
sonnyblarney#
Yup. Diminishing returns on that though. I'm happy with 3. Unless it's API or public code used by a wide audience then it needs a lot of eyes and has to be very clean.

Continue this thread — 12 more replies

Load more comments