TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

My Weird Ruby

128 pointsby adamesqueabout 10 years ago

13 comments

jfaucettabout 10 years ago
I&#x27;d also add that rubys confusion about what a function is is the thing that&#x27;s been annoying me the most lately. You have procs, lambdas, blocks, and all with subtle differences (<a href="http://awaxman11.github.io/blog/2013/08/05/what-is-the-difference-between-a-block/" rel="nofollow">http:&#x2F;&#x2F;awaxman11.github.io&#x2F;blog&#x2F;2013&#x2F;08&#x2F;05&#x2F;what-is-the-diffe...</a>), and all I want are simple funcs as first class citizens that have consistent behavior. (TCO as a default would also be nice).<p>&quot;And finally, pie in the sky, can we solve packaging apps up into distributable binaries, please? Rust and Go are making us look bad.&quot;<p>As a ruby programmer the lack of any reasonable - i.e. not hacky - way to build binaries is annoying. Unless you&#x27;re building a server side app, you can pretty much forget using ruby because of this. Maybe that&#x27;s all ruby cares about, its certainly its niche but I like ruby and would like to be able to use it for cli programs, etc. Personally, I don&#x27;t want end users of my code to have to install ruby, learn about ruby gems and boot the ruby vm before having to run a cli program.
评论 #9160991 未加载
评论 #9161512 未加载
评论 #9160734 未加载
评论 #9161357 未加载
评论 #9161420 未加载
评论 #9176549 未加载
评论 #9161549 未加载
rubyn00bieabout 10 years ago
Some small but I think important nit-picky things about Struct<p>1.) A struct in ruby isn&#x27;t just data, it is an object.<p>2.) Structs come with some weird gotchas, most notably that it is an Enumerable!<p>3.) It&#x27;s generally better to use a hash (in ruby) if you want &quot;pure&quot; data object (and they at least used to be faster).<p>I myself have written a lot of &quot;weird&quot; Ruby and I will say that more often than not it&#x27;s detrimental to an application that is used&#x2F;developed by others. Often times ideas that seem brilliant in one language, cannot be translated into another (immutability), and it&#x27;s best to use the recommended paradigms. Especially when those using the software are not familiar with them, and most likely won&#x27;t become familiar with them....<p>For me, many functional paradigms are just lost on ruby because it&#x27;s so highly mutable that practicing them is more academic than practical (sadly). That&#x27;s why I write Scala or Elixir now when I want&#x2F;need those paradigms-- because they&#x27;re the right tools for that job.<p>I definitely don&#x27;t want to discourage innovation, or bringing great ideas to ruby from other places-- I just want to emphasize caution :)
评论 #9162201 未加载
评论 #9162769 未加载
评论 #9160667 未加载
评论 #9162587 未加载
dkarapetyanabout 10 years ago
That&#x27;s not that weird. After trying to learn Haskell and reading &quot;Understanding Computation&quot; the Struct and enumerable style of structuring code feels very natural.<p>I disagree with the conclusions though. Contracts and replacing `nil` with `Maybe` doesn&#x27;t sound right to me at all since I use `nil` pretty heavily all over the place and the extra layer of `Maybe` doesn&#x27;t buy me anything. I don&#x27;t understand what he means by a dependency system since Gems have their dependencies spelled out pretty explicitly. Killing symbols is just silly because I use them to tag all sorts of stuff and message passing with symbols feels more natural than any other data type. Packaging could be better and optional types would also be nice. I like how TypeScript does it actually quite a lot.
评论 #9162508 未加载
评论 #9160805 未加载
Roboprogabout 10 years ago
Mostly that was an interesting article, but there was one pain point: having to read the parameter list to a routine <i>three</i> (!) times.<p>Honestly, why has no language (few languages?) come up with a scheme yet to put the formal parameters to a routine one per line, with documentation, like so:<p><pre><code> ... </code></pre> param-name [&lt;type, if specified&gt;] [&lt;documentation&gt;]<p><pre><code> ... </code></pre> Swap the name and type order for &quot;New Jersey&quot; style languages vs &quot;Swiss&quot; style languages as needed.<p>This is actually how I used to write out my C function headers (Frack K&amp;R layout!), even though we didn&#x27;t use a doc generator tool such as Doxygen (sp?).<p>Javadoc is only slightly less offensive, naming the parameters twice, due to slavish adherence to the altar of New Jersey formatting. I would love to see &quot;&#x2F;&#x2F;@ description...&quot; after each parameter as an alternate to &quot;* @param name description...&quot; duplication above the parameters. &quot;WET brain-death forever!&quot;, I guess.
评论 #9163843 未加载
grandalfabout 10 years ago
That Ruby looks excellent. I hadn&#x27;t realized the contracts gem existed.<p>So much of what people redundantly cram into test suites could be handled with simple contracts.
评论 #9160448 未加载
评论 #9160340 未加载
phamiltonabout 10 years ago
I&#x27;d be really interested to see success typing applied to ruby.<p><a href="http://user.it.uu.se/~kostis/Papers/succ_types.pdf" rel="nofollow">http:&#x2F;&#x2F;user.it.uu.se&#x2F;~kostis&#x2F;Papers&#x2F;succ_types.pdf</a><p>TL&#x2F;DR: Success typing considers all possible types a value can have. If a function returns either a bool or an int and you then pass that value into a function that accepts a string or an int, then the success typing checks out. It doesn&#x27;t mean your program is correct, but that it could possibly be correct. On the other hand, if you pass the &quot;bool or int&quot; value into a function that only accepts a string, the type checker will complain and you know for sure your program is incorrect. In other words, you will get false negatives but never a false positive.
评论 #9161567 未加载
评论 #9160937 未加载
wasdabout 10 years ago
Traveling Ruby is a good way to package ruby applications. <a href="https://github.com/phusion/traveling-ruby" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phusion&#x2F;traveling-ruby</a>
评论 #9176541 未加载
pjeabout 10 years ago
Ruby&#x27;s cardinal sin: there&#x27;s no way to `require` code without global side effects.<p>e.g. <a href="https://twitter.com/tomdale/status/457282269342744576" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;tomdale&#x2F;status&#x2F;457282269342744576</a>
评论 #9161391 未加载
评论 #9161315 未加载
Veedracabout 10 years ago
If you want to replace floats, what with?<p>Symbolic computation is way too expensive.<p>Fractions are good whilst they&#x27;re restricted in size but are too slow at arbitrary precision and too inaccurate with numbers not centred on 1.<p>Fixed precision decimal floating point has numerical problems because numbers scale by too large an increment. (see footnote)<p>Arbitrary precision floats don&#x27;t solve anything unless your problem was too little precision - with the precision of a 64 bit float this is rarely the case and 128 bits is massively more than that.<p>Arbitrary precision decimals don&#x27;t solve anything either.<p>Logarithmic number systems are a good contender but almost all operations become lossy. This is OK if you&#x27;re using them as approximations - which is the common use of floats - but the fact floats are exact on the integers up to a large ceiling is useful (see Javascript) as with many other of their exactness properties.<p>Even better might be a symmetric level-index number system; you get the advantages of logarithmic number systems but <i>also</i> get immunity from overflow and underflow - the only operation that isn&#x27;t closed is division by 0 and since operations can&#x27;t underflow <i>all</i> 0s are actually 0.<p>If it were me implementing a new very-high level language with only weak cares about speed (eg. faster than doing it symbolically), I&#x27;d probably choose to use fixed precision fractions that fall back to symmetric level-index numbers instead of rounding. That way I&#x27;d get precise rationals (including int64s), immunity from underflow and overflow and a smoother error curve than floats.<p>---<p>Some people are pretty surprised to hear me criticize decimal types, but they&#x27;re genuinely numerically worse than binary floating point. I&#x27;ve talked about this in depth here:<p><a href="http://www.reddit.com/r/programming/comments/2ut00j/a_little_thing_to_love_about_perl_6_and_cobol/cobl3vd" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;2ut00j&#x2F;a_little...</a><p>and I give a rough rule-of-thumb about what type to use when here:<p><a href="http://www.reddit.com/r/learnpython/comments/2wyeho/is_this_an_error_in_the_python_interpreter_if_not/covafmk" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;learnpython&#x2F;comments&#x2F;2wyeho&#x2F;is_this_...</a>
sshawabout 10 years ago
Really, that&#x27;s not weird at all. Far from it.<p>For a truly different Ruby coding style checkout some of Ara T. Howard&#x27;s code: <a href="https://github.com/ahoward" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ahoward</a>.
lancefisherabout 10 years ago
Why kill symbols?
评论 #9160816 未加载
unknownianabout 10 years ago
Is Rubinius X still a thing?
jrochkind1about 10 years ago
Is there an ETA for middleman 4.0?