[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
What's your favourite little feature more programming languages
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 60
Thread images: 3
File: lastnonzerorec.png (12 KB, 493x161) Image search: [Google]
lastnonzerorec.png
12 KB, 493x161
What's your favourite little feature more programming languages should have?

For me it's lisp's threading macro / elxir's pipe.
>>
>>55228147
for me its lisp's "this-language-is-not-utter-shit-to-work-with"

more languages should definietly have that
>>
>>55228173
Trivial thing, but kebab-case is neat, too.
>>
>>55228147
Python's context managers are pretty neat.

with open('myfile') as f:
some_stuff_that_might_bomb_but_at_least_my_file_will_be_closed(f)
>>
I really like PHP's `foreach` loop

<? foreach( $variable as $var ) {
echo $var;
}
?>
>>
>>55228147
Python's list comprehensions
>>
x, y = y, x 
>>
>>55228588
So like in most other lang's
for(int i : somethingElse)
>>
prototypal inheritence in javascript
>>
>>55228588
what's so fab about this senpai? python is below:

for x in mylist:
print x
>>
File: Capture.png (9 KB, 553x133) Image search: [Google]
Capture.png
9 KB, 553x133
http://kotlinlang.org/docs/reference/extensions.html

Kotlin's extension functions. Makes working with immutable libraries much more bearable.
>>
I love python's
enumerate
function.
>>
wrapping, unwrapping, and python's built-in data-types in general
>>
first class monad support

value1 = getNullValueIfPassedThree(3)
value2 = doSomethingThatCrashesIfPassedNull(value1)
return value2 + 3
// returns null


it just werks
>>
>>55228693
another meme language that won't be used for anything but fizzbuzzing and ebin map transforms
>>
>>55228653
True that most langs have something like that now. I think even Pascal had it.

>>55228147
Do specific macros really count as "language features"?
>>
>>55228173
what is it with lisp and huge fucking function names that almost always require hyphens
>>
>>55228693
C# has this
>>
>>55228147
I'd have to agree with you, it's a thing of beauty.
>>
>>55228767
I personally think fucking-function-name looks better and easier to parse than fkfnname or fuckingFuncionName or even fucking_function_name, but maybe it's just because I am used to it.
>>
Haskell's type classes
>>
>>55229112
This.

Also, golang strong stance on code formatting (go fmt). It's not a feature of the language per se, but it's integral to go philosophy, and it's wonderful.
>>
>>55228566
This is literally the simplest feature, C# has it too and C++ is practically built around it, why does everything think it's so amazing? A best its a simple static analysis that where the compiler finds the end of a scope (fucking simple).
Stuff like type inference, and how it can be applied beautifully even in a relatively low level language like Rust, is seriously cool.
>>
strong typing, Hack's safe method chaining, PHP's "magic functions"
>>
File: nodeasm.png (312 KB, 506x662) Image search: [Google]
nodeasm.png
312 KB, 506x662
RPG has this built in job security feature that I really like. Java plebs BTFO
>>
Lisp' defmacro special form.
>>
>>55228147
Any type being allowed to be non-nullable
>>
>>55228147
Builtin support for Software Transactional Memory.

(def bob-account (ref 50))
(def jan-account (ref 100))

(defn transfer [to from amount]
(dosync (alter to + amount)
(alter from - amount)))

(Thread. (fn []
(do (Thread/sleep 250)
(transfer bob-account jan-account 50))))

(def total (+ @bob-account @jan-account))


And we can guarantee that total will always be equal to 150.
>>
>>55228758
Useful for android, lots of niceties considering that java is stuck on 1.6 for android
>>
>>55228769
Yep, mentioned on the Kotlin page. It's a nice feature.
>>
>>55228147
How does that even work?
>>
>>55228863
I recently started with Clojure and I agree, it felt like I was dumb my whole life.
>>
>>55230798
It places m into filter as in
 (filter (fn [[_ v]] ((complement zero?) v)) m) 

And places that result into the last position of into
(into {} result-from-previous-evaluation)

and so on.

https://lispdreams.wordpress.com/2016/04/10/thread-first-thread-last-and-partials-oh-my/
implementation in scheme
>>
>>55228761
considering that lisp is 90% macros, I'd say yes.
(obviously exaggerated, but the point still stands)

>>55230289
Being Homoiconic is great.

Taught my younger sister (13) Scheme. She implemented while, complete with `continue` and `break`. Turning her into a little language theorist.

On that note, call/cc is missing is basically every language. In 20 years pythonfags will have it and act like they invented it.
>>
>>55231016
I hate Pythonfags
>>
Pattern matching like elixir or haskell

It's just so useful
>>
>>55229280
Would you say it's useful to invest time to learn go? What does it offer over other languages?
>>
>>55228767
Convention, mostly.
>>
>>55231016
Show her common lisp's loop macro. Takes about 2 1/2 pages of code to implement the most useful 90% of the CLTL loop features.
>>
>>55230798
It takes the results of the previous function and passes it in as the last parameter of the next. Basically pretending a monadic do, without any of the advantages of actually using a monad, but also without any of the disadvantages.

Without the monadic bennies it basically acts like a pipeline. F# does this with the pipeline operator "|>". E.g. "foo 1 2 3 |> bar x y |> baz z" is equivalent to "baz z (bar x y (foo 1 2 3))".
>>
Reflection
>>
>>55233095
Wow, when you say it like that, it sounds ridiculously advanced. Almost Unix-y.
>>
>>55233095
Anyway, why write that in the first place instead of just composing the function calls
>>
slices in google go

https://blog.golang.org/go-slices-usage-and-internals
>>
>>55233921
>Go's arrays are values. An array variable denotes the entire array; it is not a pointer to the first array element (as would be the case in C)

Wow, I thought the people who created Go were good at C. Turns out C was probably too hard for them.
>>
>>55232349
Depends on what software you want to write. I think it's really good for networking stuff, CLI tools, those kind of things.
That doesn't necessarily mean you should learn it. Though take into account the fact that Go is really simple, it doesn't take much time to learn.
>>
>>55233940
I definitely don't know c well, but how is that wrong? Genuine question.
>>
I am shocked and pleased by the relative usefulness and non-shit implementation of Java 8 lambdas and function references. Now I get to use dumbed-down childrens' safety function pointers in my bullshit CRUD app! Now I have a whole new way to give mouth-breathing cow-orkers migraines during code reviews!

Seriously, "invokedynamic" is da shit.
>>
goto
>>
>>55228147
currying/partial application & composition
>>
>>55235309
C arrays are complete values. Sizeof(int[5]) == sizeof(int) * 5, not sizeof(int*). They decay into pointer in nearly all situations, though, including parameter passing, which results in passing the pointer by value instead of array by value.

In fact, Go has a truly idiotic design where you pass the motherfucking arrays by value, copying the entire contents. Because that's totally smart. But wait! They totally have slices! Which are totally not pointers with bounds checking built-in. Totally
>>
>>55233863
Because you can read left to right what it's doing in order.
>>
>>55233095
explain it in haskell pls
>>
>>55228598
*haskells's
>>
>>55228708
is that a class
aka, are some objects enumerable?
in haskell, we have enum class, but no objects, just types that can borrow from any class
>>
>>55232310
tell me about elixir
>>
>>55233567
???
>>
>>55228642
definitely can't go without this one
>>
I love how well-integrated regex is in Perl. One of the reasons why perl is so good for text processing.

Events and delegates in C# are also breddy noice
>>
>>55228566
literally RAII
Thread replies: 60
Thread images: 3

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.